How To Use Rsync

Rsync:Rsync is a very flexible network-enabled syncing tool. Due to its ubiquity on Linux and Unix-like systems and its popularity as a tool for system scripts, it is included on most Linux distribu...

P
Prem Mohan Tyagi
1 min | 184 words
How To Use Rsync

Rsync:

Rsync is a very flexible network-enabled syncing tool. Due to its ubiquity on Linux and Unix-like systems and its popularity as a tool for system scripts, it is included on most Linux distributions by default.

Commands:

sudo apt -y install rsync

cd ~

mkdir testdir1

mkdir testdir2

touch testdir1/file{1..100}

To sync the contents of dir1 to dir2 on the same system, type:

rsync -r testdir1/ testdir2

a stands for “archive” and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.

rsync -a testdir1/ testdir2

Rsync provides a method for doing this by passing the -n or --dry-run options. The -v flag (for verbose) is also necessary to get the appropriate output:

rsync -anv testdir1/ testdir2

If you are transferring files that have not already been compressed, like text files, you can reduce the network transfer by adding compression with the -z option:

The -P flag is very helpful. It combines the flags --progress and --partial.

rsync -azP source destination

rsync -azP /home/vagrant/testdir root@abc.com:~/var/testdir

rsync -azP /home/vagrant/testdir root@192.168.10.10:~/var/testdir

Share this article

P

Written by

Prem Mohan Tyagi