Reverse RSYNC command practical example for backup sync

Normally everybody know to sync the backup from one server to another server using rsync command but most of us don’t know to use the rsync command as reversely to sync the backup from remote server to local server (rsync).

Say for example, Normally we will sync the backup from one server (Remote Server-1) to another server (Remote Server-2), That time we need to use the rsync command from (Remote Server-1) and do it but unfortunately the (Remote Server-2) having hardware firewall and you can’t able to sync the backup from (Remote Server-1) to (Remote Server-2). What you do ? That situation you can use the rsync command as a reverse format to fetch the backup from (Remote Server-1) to (Remote Server-2) using below format. While fetching the backup, you need to use the reverse (rsync) command at (Remote Server-2).

Reverse RSYNC command syntax :

The common syntax for Reverse RSYNC command

Syntax :# rsync [Options] [Destination-Location] [Source-Location]

Common option’s for rsync :

The below rsync option must be used in rsync commands.

a : archive mode
v : Verbose
z : compress file data
e : specify the ssh as remote shell
r : recurse into directories
delete : delete files that don’t exist on sender (system)

1) How to use the Reverse RSYNC command with standard port

Here i’m going to fetch the backup from (Remote Server-1) to (Remote Server-2) with standard port using Reverse RSYNC command.

# rsync -avz -e ssh [email protected]:/root/2daygeek.tar.gz /root/backup
The authenticity of host '82.165.133.65 (82.165.133.65)' can't be established.
RSA key fingerprint is 6f:ad:07:15:65:bf:54:a6:8c:5f:c4:3b:99:e5:2d:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '82.165.133.65' (RSA) to the list of known hosts.
[email protected]'s password:
receiving file list ... done
2daygeek.tar.gz

sent 42 bytes  received 23134545 bytes  1186389.08 bytes/sec
total size is 23126674  speedup is 1.00
[email protected] [~/backup]#

Output :

Here i’m going to check whether the backup is synced or not.

# ll -h
total 125M
drwxr-xr-x   5 root root 4.0K Dec 21 05:59 ./
dr-xr-x---. 21 root root 4.0K Dec 21 02:44 ../
-rw-------   1 root root  23M Oct 26 01:00 2daygeek.tar.gz
drwx--x--x   4 root root 4.0K Oct 19 01:01 blog/
drwx--x--x   7 root root 4.0K Nov 11 07:46 mainserver/
drwxr-xr-x   2 root root 4.0K Oct  8 10:21 mageshm/
[email protected] [~/backup]#

2) How to use the Reverse RSYNC command with non-standard port

Here i’m going to fetch the backup from (Remote Server-1) to (Remote Server-2) with non-standard port using Reverse RSYNC command.

# rsync -avz -e "ssh -p 11021" [email protected]:/root/backup/weekly/2daygeek.tar.gz /root/backup
The authenticity of host '[83.170.117.138]:11021 ([83.170.117.138]:11021)' can't be established.
RSA key fingerprint is 9c:ab:c0:5b:3b:44:80:e3:db:69:5b:22:ba:d6:f1:c9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[83.170.117.138]:11021' (RSA) to the list of known hosts.
[email protected]'s password:
receiving incremental file list
2daygeek.tar.gz

sent 30 bytes  received 23134526 bytes  1028202.49 bytes/sec
total size is 23126674  speedup is 1.00
[email protected] [~/backup]#

Output :

Here i’m going to check whether the backup is synced or not.

# ll -h
total 125M
drwxr-xr-x   5 root root 4.0K Dec 21 05:38 ./
dr-xr-x---. 21 root root 4.0K Dec 21 02:44 ../
-rw-------   1 root root  23M Oct 26 01:00 2daygeek.tar.gz
drwx--x--x   4 root root 4.0K Oct 19 01:01 blog/
drwx--x--x   7 root root 4.0K Nov 11 07:46 mainserver/
drwxr-xr-x   2 root root 4.0K Oct  8 10:21 mageshm/
[email protected] [~/backup]#

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...