Preserving file and folder permissions with rsync Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Come Celebrate our 10 Year Anniversary!How to setup linux permissions for the WWW folder?Rsync Permissions from One Server to Another - Mkdir Permission denied (13)sshd_config ForceCommand /usr/bin/rsync error “connection unexpectedly closed”command parameter in .ssh/authorized_keysRsync + public key authentication securityrsync backup remote server maintaining groups and ownerBackup maildir to windows cifs sharersync maintaining ownership and permissions between linux and windows sshRsync to remote server and change file / directory ownershipsWhy does rsync+cron fail with opendir permission denied?
What were wait-states, and why was it only an issue for PCs?
What does the black goddess statue do and what is it?
What's the difference between using dependency injection with a container and using a service locator?
Why is arima in R one time step off?
Processing ADC conversion result: DMA vs Processor Registers
Will I lose my paid in full property
When does Bran Stark remember Jamie pushing him?
France's Public Holidays' Puzzle
What is /etc/mtab in Linux?
Translate text contents of an existing file from lower to upper case and copy to a new file
Eigenvalues of the Laplacian of the directed De Bruijn graph
My admission is revoked after accepting the admission offer
Why did Israel vote against lifting the American embargo on Cuba?
Marquee sign letters
What helicopter has the most rotor blades?
Preserving file and folder permissions with rsync
A journey... into the MIND
Is Bran literally the world's memory?
How do I deal with an erroneously large refund?
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
Are there existing rules/lore for MTG planeswalkers?
What's called a person who work as someone who puts products on shelves in stores?
Not within Jobscope - Aggravated injury
Is there a possibility to generate a list dynamically in Latex?
Preserving file and folder permissions with rsync
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Come Celebrate our 10 Year Anniversary!How to setup linux permissions for the WWW folder?Rsync Permissions from One Server to Another - Mkdir Permission denied (13)sshd_config ForceCommand /usr/bin/rsync error “connection unexpectedly closed”command parameter in .ssh/authorized_keysRsync + public key authentication securityrsync backup remote server maintaining groups and ownerBackup maildir to windows cifs sharersync maintaining ownership and permissions between linux and windows sshRsync to remote server and change file / directory ownershipsWhy does rsync+cron fail with opendir permission denied?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I maintain a backup of my email accounts using this command:
sudo rsync -av --delete --progress -e "ssh -p pNumber" --rsync-path="/usr/bin/rsync" /vmail/ user@my_backup_server:/home/user/backups/vmail/
Source:
Most email folders are owned by user vmail.
Destination (backup server):
System doesn't have a user named vmail.
My question, would the above command preserve file and directory permissions even if destination machine doesn't have a user named vmail? Would it be possible to restore the files and permissions completely from destination to source even if the user names between the two machines are not the same (some missing on backup server).
linux backup permissions rsync
add a comment |
I maintain a backup of my email accounts using this command:
sudo rsync -av --delete --progress -e "ssh -p pNumber" --rsync-path="/usr/bin/rsync" /vmail/ user@my_backup_server:/home/user/backups/vmail/
Source:
Most email folders are owned by user vmail.
Destination (backup server):
System doesn't have a user named vmail.
My question, would the above command preserve file and directory permissions even if destination machine doesn't have a user named vmail? Would it be possible to restore the files and permissions completely from destination to source even if the user names between the two machines are not the same (some missing on backup server).
linux backup permissions rsync
add a comment |
I maintain a backup of my email accounts using this command:
sudo rsync -av --delete --progress -e "ssh -p pNumber" --rsync-path="/usr/bin/rsync" /vmail/ user@my_backup_server:/home/user/backups/vmail/
Source:
Most email folders are owned by user vmail.
Destination (backup server):
System doesn't have a user named vmail.
My question, would the above command preserve file and directory permissions even if destination machine doesn't have a user named vmail? Would it be possible to restore the files and permissions completely from destination to source even if the user names between the two machines are not the same (some missing on backup server).
linux backup permissions rsync
I maintain a backup of my email accounts using this command:
sudo rsync -av --delete --progress -e "ssh -p pNumber" --rsync-path="/usr/bin/rsync" /vmail/ user@my_backup_server:/home/user/backups/vmail/
Source:
Most email folders are owned by user vmail.
Destination (backup server):
System doesn't have a user named vmail.
My question, would the above command preserve file and directory permissions even if destination machine doesn't have a user named vmail? Would it be possible to restore the files and permissions completely from destination to source even if the user names between the two machines are not the same (some missing on backup server).
linux backup permissions rsync
linux backup permissions rsync
asked 8 hours ago
W.M.W.M.
1203
1203
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
What rsync copies is the numerical user id of the file, regardless if it exists on the target system. If a user with that id doesn't exist, ls etc. will just show that number instead of a name. If that user id belongs to another username on the target system, this user will now own the file.
Backup and restore will work without a problem in this scenario.
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
add a comment |
How rsync preserves ownership of files depends on two things:
Are you super-user (root) on the destination?
Otherwise you can't create files and directories with a different user other than your own.Which option flags are you using?
The -a option includes the -o, --owner, -g, --group options designed to preserve ownership.
At the file-system level user and group ownership is stored in UID resp. GID numbers. When there is no mapping from UID/GID's to usernames and groupnames tools will simply display those numbers instead.
Users and groups with the same names can have different UID/GID numbers on different systems.
By default rsync will try to match the ownership by username resp. groupname. In other words when the user vmail is the owner of a file at the source, rsync will make the user vmail also the owner at the destination (even when they have different UID/GID numbers).
That is usually quite resilient and the most predictable for humans as we normally don't look at ownership in the form of UID/GID numbers.
When no matching user vmail is present on the remote destination, then a fall-back scenario will happen. Rsync will then preserve the actual underlying UID/GID numbers and the UID number of the vmail user on the source will used to set the owner.
That should preserver the correct ownership when you reverse the rsync direction and restore the backup.
man rsync :
-o, --owner
This option causes rsync to set the owner of the destination file to be the same as the source file,
but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super
options). Without this option, the owner of new and/or transferred files are set to the invoking user
on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the
ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--numeric-ids
With this option rsync will transfer numeric group and user IDs rather than using user and group names
and mapping them at both ends.
By default rsync will use the username and groupname to determine what ownership to give files. The
special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids
option is not specified.
If a user or group has no name on the source system or it has no match on the destination system, then
the numeric ID from the source system is used instead. See also the comments on the "use chroot" set‐
ting in the rsyncd.conf manpage for information on how the chroot setting affects rsync’s ability to
look up the names of the users and groups and what you can do about it.
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) asrootand not as a normal user?
– W.M.
6 hours ago
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964229%2fpreserving-file-and-folder-permissions-with-rsync%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
What rsync copies is the numerical user id of the file, regardless if it exists on the target system. If a user with that id doesn't exist, ls etc. will just show that number instead of a name. If that user id belongs to another username on the target system, this user will now own the file.
Backup and restore will work without a problem in this scenario.
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
add a comment |
What rsync copies is the numerical user id of the file, regardless if it exists on the target system. If a user with that id doesn't exist, ls etc. will just show that number instead of a name. If that user id belongs to another username on the target system, this user will now own the file.
Backup and restore will work without a problem in this scenario.
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
add a comment |
What rsync copies is the numerical user id of the file, regardless if it exists on the target system. If a user with that id doesn't exist, ls etc. will just show that number instead of a name. If that user id belongs to another username on the target system, this user will now own the file.
Backup and restore will work without a problem in this scenario.
What rsync copies is the numerical user id of the file, regardless if it exists on the target system. If a user with that id doesn't exist, ls etc. will just show that number instead of a name. If that user id belongs to another username on the target system, this user will now own the file.
Backup and restore will work without a problem in this scenario.
answered 7 hours ago
Sven♦Sven
87.9k10148201
87.9k10148201
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
add a comment |
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
2
2
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
By default rsync will use the username and groupname to determine what ownership to give files on the remote system, not the UID/GID numbers. If a user or group has no name on the source system or it has no match on the destination system, only then the numeric ID from the source system will be used.
– HBruijn
7 hours ago
add a comment |
How rsync preserves ownership of files depends on two things:
Are you super-user (root) on the destination?
Otherwise you can't create files and directories with a different user other than your own.Which option flags are you using?
The -a option includes the -o, --owner, -g, --group options designed to preserve ownership.
At the file-system level user and group ownership is stored in UID resp. GID numbers. When there is no mapping from UID/GID's to usernames and groupnames tools will simply display those numbers instead.
Users and groups with the same names can have different UID/GID numbers on different systems.
By default rsync will try to match the ownership by username resp. groupname. In other words when the user vmail is the owner of a file at the source, rsync will make the user vmail also the owner at the destination (even when they have different UID/GID numbers).
That is usually quite resilient and the most predictable for humans as we normally don't look at ownership in the form of UID/GID numbers.
When no matching user vmail is present on the remote destination, then a fall-back scenario will happen. Rsync will then preserve the actual underlying UID/GID numbers and the UID number of the vmail user on the source will used to set the owner.
That should preserver the correct ownership when you reverse the rsync direction and restore the backup.
man rsync :
-o, --owner
This option causes rsync to set the owner of the destination file to be the same as the source file,
but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super
options). Without this option, the owner of new and/or transferred files are set to the invoking user
on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the
ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--numeric-ids
With this option rsync will transfer numeric group and user IDs rather than using user and group names
and mapping them at both ends.
By default rsync will use the username and groupname to determine what ownership to give files. The
special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids
option is not specified.
If a user or group has no name on the source system or it has no match on the destination system, then
the numeric ID from the source system is used instead. See also the comments on the "use chroot" set‐
ting in the rsyncd.conf manpage for information on how the chroot setting affects rsync’s ability to
look up the names of the users and groups and what you can do about it.
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) asrootand not as a normal user?
– W.M.
6 hours ago
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
add a comment |
How rsync preserves ownership of files depends on two things:
Are you super-user (root) on the destination?
Otherwise you can't create files and directories with a different user other than your own.Which option flags are you using?
The -a option includes the -o, --owner, -g, --group options designed to preserve ownership.
At the file-system level user and group ownership is stored in UID resp. GID numbers. When there is no mapping from UID/GID's to usernames and groupnames tools will simply display those numbers instead.
Users and groups with the same names can have different UID/GID numbers on different systems.
By default rsync will try to match the ownership by username resp. groupname. In other words when the user vmail is the owner of a file at the source, rsync will make the user vmail also the owner at the destination (even when they have different UID/GID numbers).
That is usually quite resilient and the most predictable for humans as we normally don't look at ownership in the form of UID/GID numbers.
When no matching user vmail is present on the remote destination, then a fall-back scenario will happen. Rsync will then preserve the actual underlying UID/GID numbers and the UID number of the vmail user on the source will used to set the owner.
That should preserver the correct ownership when you reverse the rsync direction and restore the backup.
man rsync :
-o, --owner
This option causes rsync to set the owner of the destination file to be the same as the source file,
but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super
options). Without this option, the owner of new and/or transferred files are set to the invoking user
on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the
ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--numeric-ids
With this option rsync will transfer numeric group and user IDs rather than using user and group names
and mapping them at both ends.
By default rsync will use the username and groupname to determine what ownership to give files. The
special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids
option is not specified.
If a user or group has no name on the source system or it has no match on the destination system, then
the numeric ID from the source system is used instead. See also the comments on the "use chroot" set‐
ting in the rsyncd.conf manpage for information on how the chroot setting affects rsync’s ability to
look up the names of the users and groups and what you can do about it.
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) asrootand not as a normal user?
– W.M.
6 hours ago
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
add a comment |
How rsync preserves ownership of files depends on two things:
Are you super-user (root) on the destination?
Otherwise you can't create files and directories with a different user other than your own.Which option flags are you using?
The -a option includes the -o, --owner, -g, --group options designed to preserve ownership.
At the file-system level user and group ownership is stored in UID resp. GID numbers. When there is no mapping from UID/GID's to usernames and groupnames tools will simply display those numbers instead.
Users and groups with the same names can have different UID/GID numbers on different systems.
By default rsync will try to match the ownership by username resp. groupname. In other words when the user vmail is the owner of a file at the source, rsync will make the user vmail also the owner at the destination (even when they have different UID/GID numbers).
That is usually quite resilient and the most predictable for humans as we normally don't look at ownership in the form of UID/GID numbers.
When no matching user vmail is present on the remote destination, then a fall-back scenario will happen. Rsync will then preserve the actual underlying UID/GID numbers and the UID number of the vmail user on the source will used to set the owner.
That should preserver the correct ownership when you reverse the rsync direction and restore the backup.
man rsync :
-o, --owner
This option causes rsync to set the owner of the destination file to be the same as the source file,
but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super
options). Without this option, the owner of new and/or transferred files are set to the invoking user
on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the
ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--numeric-ids
With this option rsync will transfer numeric group and user IDs rather than using user and group names
and mapping them at both ends.
By default rsync will use the username and groupname to determine what ownership to give files. The
special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids
option is not specified.
If a user or group has no name on the source system or it has no match on the destination system, then
the numeric ID from the source system is used instead. See also the comments on the "use chroot" set‐
ting in the rsyncd.conf manpage for information on how the chroot setting affects rsync’s ability to
look up the names of the users and groups and what you can do about it.
How rsync preserves ownership of files depends on two things:
Are you super-user (root) on the destination?
Otherwise you can't create files and directories with a different user other than your own.Which option flags are you using?
The -a option includes the -o, --owner, -g, --group options designed to preserve ownership.
At the file-system level user and group ownership is stored in UID resp. GID numbers. When there is no mapping from UID/GID's to usernames and groupnames tools will simply display those numbers instead.
Users and groups with the same names can have different UID/GID numbers on different systems.
By default rsync will try to match the ownership by username resp. groupname. In other words when the user vmail is the owner of a file at the source, rsync will make the user vmail also the owner at the destination (even when they have different UID/GID numbers).
That is usually quite resilient and the most predictable for humans as we normally don't look at ownership in the form of UID/GID numbers.
When no matching user vmail is present on the remote destination, then a fall-back scenario will happen. Rsync will then preserve the actual underlying UID/GID numbers and the UID number of the vmail user on the source will used to set the owner.
That should preserver the correct ownership when you reverse the rsync direction and restore the backup.
man rsync :
-o, --owner
This option causes rsync to set the owner of the destination file to be the same as the source file,
but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super
options). Without this option, the owner of new and/or transferred files are set to the invoking user
on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the
ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--numeric-ids
With this option rsync will transfer numeric group and user IDs rather than using user and group names
and mapping them at both ends.
By default rsync will use the username and groupname to determine what ownership to give files. The
special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids
option is not specified.
If a user or group has no name on the source system or it has no match on the destination system, then
the numeric ID from the source system is used instead. See also the comments on the "use chroot" set‐
ting in the rsyncd.conf manpage for information on how the chroot setting affects rsync’s ability to
look up the names of the users and groups and what you can do about it.
edited 6 hours ago
answered 7 hours ago
HBruijnHBruijn
56.9k1190150
56.9k1190150
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) asrootand not as a normal user?
– W.M.
6 hours ago
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
add a comment |
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) asrootand not as a normal user?
– W.M.
6 hours ago
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) as
root and not as a normal user?– W.M.
6 hours ago
Thanks for the detailed answer. So, you're saying that I should connect (login) to the destination machine (backup server) as
root and not as a normal user?– W.M.
6 hours ago
2
2
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
As a normal user you can't create files that don't belong to you, so you need to either log in as root on the destination, or you have to be root locally and run rsync in the opposite direction and pull the files in.
– HBruijn
6 hours ago
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964229%2fpreserving-file-and-folder-permissions-with-rsync%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown