rsync
rsync [OPTIONS] SOURCE DESTINATION
Notes
- Incomplete. For reading on man page and Arch wiki necessary.
- For obscure/advanced commands, read the man page; there are lots of caveats.
Full system back-up
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}
Flags
-
- a: archive mode; equals-rlptgoD. In other words:-r: recurse.-l: copy symlinks as symlinks.-p: preserve permissions.-t: preserve modification times.-g: preserve group.-o: preserve owner.-D: preserve device files (requires root) and special files. -
-H: preserve hard links. -
-A: preserve ACLS. Activates-pas well. -
-X: preserve extended attributes. -
-E: preserve executability. -
-e ssh: use ssh. Other shells can be used with-e SHELLas well. -
-c: work out what to sync based on checksum, not mod-time & size.Substantially slower.
-
-I: don’t skip files that match size and time. -
-uSkip files that are newer on the receiver. Caveats; read man page. Use with care as
-ucan cause unintended consequences. -
-n: dry-run. -
-v: verbose. -
-P:-partialand--progress.--progress: progress bar.--partial: keep partial transfers rather than deleting them. -
--partial-dir=DIR: keep partial transfers in a specific directory.Ex:
--partial-dir=.rsync-partial. May need to be in an exclude rule. See man page. Avoid/tmpand other directors writable by any user. -
-h: human-readable numbers. -
i: output a change summary for all updates. -
z: compress files during the transfer. -
-R: relative paths. Preserves the full path of the file on the source.Ex: if
/home/james/stuffis rsynced to/tmpthe resulting path would be/tmp/home/james/stuff. -
--delete: delete extaneous files from destination directories.Avoid
/*with this option as it doesn’t work as expected. Top-level files are not included. -
--max-size=SIZE: max size in K, M, or G. 1024K = 1B.For decimal use KB, MB, or GB.
-
--min-size=SIZE: min size in K, M, or G. 1024k = 1B.For decimal use KB, MB, or GB.
-
list-only: list the files instead of copying. -
--stats: file transfer stats. -
--log-file=FILE: logs actions to a file. -
-4: prefer IPv4. -
-6Prefer IPv6.
-
--noatimeDo not alter atime when opening source files.
-
--exclude={"DIR1","DIR2",...,"DIRN"}Exclude directories. Also see
--exclude-fromin man; this pulls excludes from a file.includeandinclude-fromcan be used to override exclude. -
--info=progress2Show overall progress and transfer speed.
-
-xDon’t cross a filesystem boundry.
-
--usermap=STRING, --groupmap=STRINGMap users and groups on the remote and local system.
STRING=FROM1:TO1,FROM2:TO2,etcEx:
--usermap=0-99:nobody,wayne:admin,*:normal --groupmap=usr:1,1:usrMap UIDs 0-99 to nobody. Map wayne to admin: Map anything not matched so far to normal.Requires
-oforusermapand-gforgroupmap. -
--chown=USER:GROUPSpecify user and group for destination files. Not compatible with
--usermapand--groupmap. BothUSERandGROUPcan be left empty. IfUSERis empty, the colon should be retained. -
--timeout=TIMEOUTMaximum I/O timeout in seconds. Default is 0.
-
-b,--backupRename and retain pre-existing destination files. Caveats for
--delete; read man. If not used with--backup-dir -
--backup-dir=DIRFor use with
-b. Specify a directory that pre-existing destination files are moved to. If--suffixis not used, the files retain their names. Relative paths are relative to DESTINATION. -
--suffix=SUFFIXOverride the default suffix. If
--backup-diris not specified, the default suffix is~/ -
--compare-dest=DIRThe files in DIR are compared in addition to the files in DESTINATION. If files exist in either destinations, they are ignored. This option can be used multiple times.
Can be used to make incremental back-ups.