Skip to content

Instantly share code, notes, and snippets.

@rahilwazir
Last active August 4, 2016 16:05
Show Gist options
  • Save rahilwazir/2e3c2b42561638e3894febc888ac182d to your computer and use it in GitHub Desktop.
Save rahilwazir/2e3c2b42561638e3894febc888ac182d to your computer and use it in GitHub Desktop.
rsync to sync files

Sync files/folders between two host

rsync -azP -e 'ssh -i /path/to/id_rsa_private_key' /files/source destination_host_user@111.111.111.111:/destination/path

Be sure to add ssh-add /path/to/id_rsa_private_key

Options:

  • -a It stands for "archive" and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
  • -z reduces the network transfer by adding compression
  • -P It combines the flags --progress and --partial. The first of these gives you a progress bar for the transfers and the second allows you to resume interrupted transfers
  • -e command to execute

Reference DO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment