4

Can rsync be used to create and maintain an exact copy of a filesystem remotely, detecting owner or group or permission changes too?

My current "rsync --del --numeric-ids -a something/ root@host:/somewhere/" only syncs by time or (or --checksum). If, say, only owner changes nothing is syncd. The workaround is to delete everything and resync, wearing out the targets flash storage.

If not, is there another way?

My goal is to be able to have networked hdd with that is an exact duplicate and can simply be plugged into the source machine in the event of a device/fs failure, or (my main reason) to sync an embedded os accross the network that has had only minor (but numerous untracked) tweeks.

EDIT: Original command used root@host not user@host

rick
  • 41
  • 2
  • 1
    -I or -c might do it, at the cost of a lot of extra reads & time (which at least are better than a lot of extra writes & time). But honestly I thought rsync already updated permissions by default with -p (or anything that includes it, like -a) – derobert May 23 '17 at 20:18
  • Wait... when you say you're destination is user@host, do you mean a non-root user? Only root can change ownership. – derobert May 23 '17 at 20:20
  • Ok... then which version of rsync on each side? Is your network hard drive running Unix, and using a filesystem (e.g., ext4) that supports Unix permissions? I tested with 3.1.2 (source) speaking to 3.0.9 (destination) and that copied over user and group changes with rsync --del --numeric-ids -a /tmp/test root@host:/tmp. – derobert May 23 '17 at 20:47
  • Oh—also, are you somehow changing the owner/group without changing the inode change time (st_ctime)? – derobert May 23 '17 at 20:52

1 Answers1

-1

Check out this similar question.

You can use the following flags to preserve that specific information:

-p Preserve permissions

-o Preserve owner

-g Preserve group

-X Preserve Extended Attributes

-A Preserve File ACLs

Patrick
  • 599
  • OP appears to already have -a. – derobert May 23 '17 at 20:04
  • -a is different than -A. -a is archive. -A is preserve file ACLs. – Patrick May 23 '17 at 20:12
  • 1
    Archive includes -p, -o, and -g. From the rsync manpage: -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X). So permissions, owner, and group should already be preserved. – derobert May 23 '17 at 20:14
  • My error. I have all along been using root@ – rick May 23 '17 at 20:42
  • 2
    rsync -a does not detect changed permissions if the dates and size are the same.

    I accidentally did an rsync without --numeric-ids and then tried to fix it. Couldn't. That's what led me to realize this.

    Rsync does not compare attributes, only sets them for files copied.

    – rick May 23 '17 at 20:44