0

I know that there are a lot of treads about this subject, but I was unable to solve it.

I'd like to make a simple backup with rsync between my hard drive and a USB device. My original directories and files have different permissions (0664, 0644, 0444, 0755, etc.).

I tried various option, the basic one is

rsync -avzu --delete --delete-after --progress /source /target

(and -a implies -p, which «preserve permissions», as says the linux man page). But in the USB device I find all permissions set to 0777, independently of issuing the command as simple user or as root.

The device is mounted in /media (I'm working on a Debian machine) and its permissions are automatically set to 0777. So, I have the impression that rsync is limited to giving the device permissions to files and directories, instead of keeping the original ones.

Is there a way to solve with rsync, or have I to change permissions at a later time with chmod?

3
  • 2
    What filesystem is your usb stick? How is it mounted and what are parameters?
    – Yurko
    Feb 26, 2020 at 17:39
  • 2
    If the filesystem on the USB drive does not support Unix permissions (and/or ownership etc.), then this meta-data can not be preserved.
    – Kusalananda
    Feb 26, 2020 at 18:00
  • computer filesystem is ext4. USB stick filesystem is NTFS; it's mounted automatically: where can I desume the options? Or simply NTFS doesn't support linux permission? I'm from many years a Linux user, so I'm not so aware of Windows permissions...
    – user41063
    Feb 26, 2020 at 18:38

1 Answer 1

0

You may not be using ACLs on your ext4 (source) filesystem. NTFS is going to want ACLs only. rsync is not going to translate a POSIX style (ugo) permission to an ACL.

If you do have existing ACLs on your ext4, you can try to transfer them with -A or --acls.

5
  • root@darkstar:~# tune2fs -l /dev/sdc4 | grep "Default mount options" Default mount options: user_xattr acl. I tried: rsync -avzuA --delete --delete-after --progress /source /target. but the permissions are not the original ones: still changed in 0777. Or is there anything wrong in the options I pass to rsync?
    – user41063
    Feb 26, 2020 at 19:52
  • All rsync is doing is trying to recreate via a chmod() call. What happens if you try it yourself and do chmod 0644 /target/file? If the filesystem doesn't honor that call, then the information is discarded.
    – BowlOfRed
    Feb 26, 2020 at 20:35
  • I tried with chmod regardless of rsync, and nothig happens. Is there a way to solve with or without rsync? Have I to do anything on USB stick filesystem?
    – user41063
    Feb 26, 2020 at 20:44
  • Your choices might be: use something other than rsync to encode the perms in another way (like tar), or use another filesystem on the USB (NTFS is okay for interoperability, but ext would hold the permissions properly). I don't know of anything like rsync, but which encodes the permissions in a hidden file or similar. Tar keeps the perms, but makes it harder to do incremental updates.
    – BowlOfRed
    Feb 26, 2020 at 21:37
  • I need a NTFS system for interoperability. In the school where I teach almost all computers use Windows, so I couldn't read a ext filesystem. I'll try tar. Thank you!
    – user41063
    Feb 26, 2020 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .