Transfer files either to or from a remote host. Can transfer single files, or multiple files matching a pattern.
# To transfer file from local to remote host: rsync <path/to/file> <remote_host_name>:<remote_host_location> # To transfer file from remote host to local: rsync <remote_host_name>:<remote_file_location> <local_file_location> # To transfer file in archive (to preserve attributes) and compressed (zipped) mode with verbose and human-readable progress: rsync -azvhP <path/to/file> <remote_host_name>:<remote_host_location> # To transfer a directory and all its children from a remote to local: rsync -r <remote_host_name>:<remote_folder_location> <local_folder_location> # To transfer only updated files from remote host: rsync -ru <remote_host_name>:<remote_folder_location> <local_folder_location> # To transfer file over SSH and delete local files that do not exist on remote host: rsync -e ssh --delete <remote_host_name>:<remote_file> <local_file> # To transfer file over SSH and show global progress: rsync -e ssh --info=progress2 <remote_host_name>:<remote_file> <local_file> # --- # copy files from remote to local, maintaining file propertires # and sym-links (-a), zipping for faster transfer (-z), verbose (-v). $ rsync -avz host:file1 :file1 /dest/ $ rsync -avz /source host:/dest # Copy files using checksum (-c), rather than time, to detect if the file # has changed. Useful for validating backups. $ rsync -avc /source/ /dest/ # --archive archive mode # --checksum skip based on checksum, not mod-time and size # --progress show progress during transfer # --delete extraneous files from dest dirs # --delete-excluded also delete excluded files from dest dirs # --force force deletion of dirs even if not empty # --ignore-errors delete even if there are I/O errors # --human-readable output numbers in a human-readable format # -- exclude exludes file(s) from syncing $ rsync --archive \ --checksum \ --progress \ --delete \ --delete-excluded \ --force \ --ignore-errors \ --human-readable \ --exclude '*.pyc' \ --exclude '.DS_Store' \ <source_dir> <dest_dir>