rsync's Examples

the syntax to transfer a file from your local system to a remote server. It is also called a “push” operation.

rsync local_file_path user@remote-host:remote_file_path

 how to transfer a file from a remote server to your local system, also called a “pull” operation.

rsync user@remote-host:remote_file_path local_file_path

If you add the -r option, RSync will execute a recursive file transfer. This is useful when working with directories.

rsync -r user@remote-host:remote_directory/ local_directory

The -a flag is used to preserve symbolic links while transferring files. The archive flag also preserves special and device files, modification times, and permissions from the source directory.

rsync -a user@remote-host:remote_directory/ local_directory

compress files using the -z flag. Compressing files can reduce network load and speed up file transfer.

rsync -az user@remote-host:remote_directory/ local_directory

You can use the -P flag to know the progress of the file transfer. With Rsync, you can also resume file transfers if they are interrupted.You can use the -P flag to know the progress of the file transfer. With Rsync, you can also resume file transfers if they are interrupted.

rsync -aP user@remote-host:remote_directory/ local_directory

the verbose command can help you understand every step of the file transfer. You can use the -v flag 

rsync -av user@remote-host:remote_directory/ local_directory

use the help command with RSnsc to get a list of all the options and flags

rsync --help

 Rsync’s --backup option can be used to store backups of important files. It’s used in conjunction with the --backup-dir option, which specifies the directory where the backup files should be stored

rsync -a --delete --backup --backup-dir=/path/to/backups /path/to/source destination

you can override that exclusion for files that match a different pattern by using the --include= option

rsync -a --exclude=pattern_to_exclude --include=pattern_to_include source destination

You can change this behavior with the --delete option. Before using this option, you can use -n, the --dry-run option, to perform a test to prevent unwanted data loss

rsync -an --delete source destination

 if you were to run rsync with -azP again, you’ll notice in the output how Rsync intelligently re-copies only the changed files

rsync -azP source destination

DevOpsSchool
Typically replies within an hour

DevOpsSchool
Hi there 👋

How can I help you?
×
Chat with Us