Skip to main content

Rsync

Syntax​

rsync [options] source [destination]

Options:

  • -a, --archive copy all metadata with sync (symbolic links, file permissions, user & group ownership and timestamps etc.)
  • -v, --verbose will give you summary of process
  • -h, --human-readable format Outputs in a human readable format.
  • -z, --compress compress file data during the transfer

Local​

Copy data from foo to bar​

rsync -avh foo/ bar/

Remote​

Basics​

rsync local-file user@remote-host:remote-file

Rsync using ssh​

rsync -avhze ssh /foo user@remote-host:/tmp/

Rsync with particular file permissions​

rsync -avhe ssh --chown=USER:GROUP /foo user@remote-host:/tmp/

Rsync with --ignore-existing-files​

Does not ignore directory

rsync --ignore-existing -avhe /foo user@remote-host:/tmp/

Show progress during transfer​

rsync -avhe ssh --progress /foo user@remote-host:/tmp/

Update the remote only if there is a newer version is on the local filesystem ( timestampz based )​

rsync -avhe ssh --progress --update /foo root@remote-host:/tmp/

Automatically delete files from local-host after successful transferring​

delete only files not directories

rsync -avhe ssh --remove-source-files /foo user@backup-server:/tmp

Performing a Dry run with rsync​

rsync -avhe ssh --dry-run --chown=USER:GROUP /foo user@remote-host:/