RSYNC Commands Cheat Sheet

Here is a cli commands cheat sheet for RSYNC command, you can use this as a quick reminder for basic commands with a brief description for each of the commands.

What is RSYNC command?

Add some data here

        # To copy files from remote to local, maintaining file properties and sym-links
# (-a), zipping for faster transfer (-z), verbose (-v):
rsync -avz host:file1 :file1 /dest/
rsync -avz /source host:/dest

# To copy files using checksum (-c) rather than time to detect if the file has
# changed. (Useful for validating backups):
rsync -avc  

# To copy /src/foo folder into destination:
# This command will create /dest/foo if it does not already exist
rsync -auv /src/foo /dest

# To copy contents of /src/foo into destination:
# This command will not create /foo_bak/foo folder
rsync -auv /src/foo/ /foo_bak

# To copy file from local to remote over ssh with non standard port 1234 to
# destination folder in remoteuser's home directory:
rsync -avz -e "ssh -p1234"  @:

# Use the specified authentication key, instead of typing a password:
# (The key can be generated by ssh-keygen, and the public key should be placed
# in remote's authorized_keys, e.g. using ssh-copy-id)
rsync -avz -e "ssh -i ~/.ssh/id_rsa"  

# Log into remote as a user, but promote to root, to access privileged files:
rsync -avz --rsync-path="sudo rsync" user@ 

# Rsync only symlinks and preserve them as symlinks (dont follow them):
find /path/to/files -type l -print | \
  rsync -av --files-from=- /path/to/files user@targethost:/dest_path
    

Check out the RSYNC command documentation .


You can also check our MegaSh cheatsheet tool, that has 150+ searchable linux cheat sheets in one page, so you never forget a command as you work again

Check Also

Best AI tools list