Rsync

From Colettapedia
Jump to navigation Jump to search

General

  • There are two different ways for rsync to contact a remote system: using a remote-shell program as the transport (such as ssh or rsh) or contacting an rsync daemon directly via TCP

Examples

  • rsync -av -e ssh remoteuser@remotehost:/remote/dir /this/dir/
    • -a = archive = -rlptgoD
    • -r = copy directories recursively
    • -l = --links = When symlinks are encountered, recreate the symlink on the destination.
    • -p = --perms = This option causes the receiving rsync to set the destination permissions to be the same as the source permissions.
    • -t = --times = This tells rsync to transfer modification times along with the files and update them on the remote system.
    • -o = --owner
    • -g = --group
    • -D = --devices --specials
  • check using the --delete option by first using the --dry-run (-n) option
  • rsync -av --exclude 'subdir' ./TopLevelDir /Destination/Path
    • note the double dash in exclude
    • arg to --exclude can be a glob
  • rsync -av -e ssh --filter="+ */" --filter="+ *.mp4" --filter="- *" gpu1:/home/shumakercd/raw_rosti_videos .
    • Use filter to add/subtract items to file list
    • find . -type d -empty -delete to remove empty directories after