Previous: , Up: Backup   [Contents][Index]


14.3.1.3 Copying vs. Renaming

You can make backup files by copying the old file or by renaming it. This makes a difference when the old file has multiple names. If you rename the old file into the backup file, the alternate names become names for the backup file. If you copy the old file instead, the alternate names remain names for the file that you are editing, and the contents accessed by those names will be the new contents.

How you make a backup file may also affect the file’s owner and group. If you use copying, they do not change. If renaming is used, you become the file’s owner, and the file’s group becomes the default (different operating systems have different defaults for the group).

Having the owner change is usually a good idea, because then the owner is always the person who last edited the file. Occasionally there is a file whose owner should not change. Since most files should change owners, it is a good idea to use local variable lists to set backup-by-copying-when-mismatch for the special cases where the owner should not change (see File Variables).

Three variables control the choice of renaming or copying. Normally, renaming is done. If the variable backup-by-copying is non-nil, copying is used. Otherwise, if the variable backup-by-copying-when-linked is non-nil, copying is done for files that have multiple names, but renaming may still be done when the file being edited has only one name. If the variable backup-by-copying-when-mismatch is non-nil, copying is done if renaming would cause the file’s owner or group to change.


Previous: , Up: Backup   [Contents][Index]