Backup with cp -a and rsync -a do not preserver permissions and ownerships
Hi all,
I try to perform a backup of my users home directory on Ubuntu 16.04 server edition, but I am failing to get the files and directories copied while preserving their permissions and ownerships. I guess I am missing something in principle here. The details:
The question is: What is wrong with my setup? Is it something related with my external drive? Some configuration I need to do? How can I copy everything preserving the permissions and ownership? Thanks, j. |
Welcome to LinuxQuestions.
In a nutshell linux file permissions are not compatible with FAT or NTFS. There are several options but if you do not need to use the drive on Windows anymore you could reformat it to a linux filesystem like ext4. You could create an archive using tar for example and save the file to the external drive. Permissions will be preserved and you can still connect the drive to a Windows PC. |
You are also able to specify which user, group and file permissions you want on the whole drive(not individually), in your /etc/fstab file or in a mount command. for user and group 501, and 777 permissions, try:
Code:
mount -t vfat /dev/sda1 /mnt/hdd -o rw,uid=501,gid=501,dmask=0000,fmask=0000 |
If you need to use FAT for the backup drive, and you need to preserve Linux permissions, you could create a tar archive of the listed folders and store the archive on the backup drive. It's not ideal, because there's an extra step each way in the archiving/restoring procedure, but given your current setup it may be acceptable.
Edit: oops, sorry I just noticed michaelk already said that :o |
Quote:
If this is strictly a backup operation and the target device will NOT be mounted on a Windows system: Put a linux native filesystem on the destination, then do the rsync/cp. This way the proper access controls, owners, groups (and security labels if any) will be preserved. |
All times are GMT -5. The time now is 08:03 AM. |