rsync Command
rsync means remote sync. rsync is a utility provided by linux to synchronize the files and folders from one location to another on same or remote server. rsync is basically used to perform backup task on Linux servers.
Key features of rsync are :
1). Speed : the main and important feature is rsync is it's speed. As it will replicate the full content between source and destination fro the first time.
But, on next time it will transfer only those files which are changed or modified. it makes it really fast.
2). Security : Data is encrypted using SSH during transfer which gives more security.
3). Less bandwidth : As it do not transfer the whole content but only the modified one and also uses commpression and decompression of data at both ends uses less bandwidth to transfer.
Syntax :
------
# rsync options source destination
------
Source and destination could be either local or remote.
Examples of rsync Command :
1). Synchronize Two Directories on a Local Server :
------
# rsync -zvr /home/hoststud/tmp/ /root/temp
------
-z is to enable compression
-v verbose
-r indicates recursive
2). Synchronize Only One File :
------
# rsync -v /home/hoststud/tmp/ /root/temp
------
3). Synchronize Files From Local to Remote :
------
# rsync -avz /root/mails/ hoststud@192.168.101.1:/home/hoststud/mails/
Password:
------
To do remote synchronization you will need username and ip-address of the remote server. The format is username@machinename: path
4). Synchronize Files From Remote to Local :
------
# rsync -avz hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
5). Do Not Overwrite the Modified Files at the Destination :
------
# rsync -avzu hoststud@192.168.101.1:/var/temp /root/temp
Password:
------
When a file is modified at the destination, and we not want to overwrite the file with the old file from the source. we can use rsync -u option to do not overwrite it.
6). Synchronize only the Directory Tree Structure (not the files) :
------
# rsync -v -d hoststud@192.168.101.1:/home/hoststud/ .
------
7). View the rsync Progress during Transfer :
------
# rsync -avz --progress hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
rsync –progress option displays detailed progress of rsync execution.
8). Delete the Files Created at the Target :
------
# rsync -avz --delete hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
If a file is not present at the source, but present at the target, you might want to delete the file at the target during rsync.
rsync means remote sync. rsync is a utility provided by linux to synchronize the files and folders from one location to another on same or remote server. rsync is basically used to perform backup task on Linux servers.
Key features of rsync are :
1). Speed : the main and important feature is rsync is it's speed. As it will replicate the full content between source and destination fro the first time.
But, on next time it will transfer only those files which are changed or modified. it makes it really fast.
2). Security : Data is encrypted using SSH during transfer which gives more security.
3). Less bandwidth : As it do not transfer the whole content but only the modified one and also uses commpression and decompression of data at both ends uses less bandwidth to transfer.
Syntax :
------
# rsync options source destination
------
Source and destination could be either local or remote.
Examples of rsync Command :
1). Synchronize Two Directories on a Local Server :
------
# rsync -zvr /home/hoststud/tmp/ /root/temp
------
-z is to enable compression
-v verbose
-r indicates recursive
2). Synchronize Only One File :
------
# rsync -v /home/hoststud/tmp/ /root/temp
------
3). Synchronize Files From Local to Remote :
------
# rsync -avz /root/mails/ hoststud@192.168.101.1:/home/hoststud/mails/
Password:
------
To do remote synchronization you will need username and ip-address of the remote server. The format is username@machinename: path
4). Synchronize Files From Remote to Local :
------
# rsync -avz hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
5). Do Not Overwrite the Modified Files at the Destination :
------
# rsync -avzu hoststud@192.168.101.1:/var/temp /root/temp
Password:
------
When a file is modified at the destination, and we not want to overwrite the file with the old file from the source. we can use rsync -u option to do not overwrite it.
6). Synchronize only the Directory Tree Structure (not the files) :
------
# rsync -v -d hoststud@192.168.101.1:/home/hoststud/ .
------
7). View the rsync Progress during Transfer :
------
# rsync -avz --progress hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
rsync –progress option displays detailed progress of rsync execution.
8). Delete the Files Created at the Target :
------
# rsync -avz --delete hoststud@192.168.101.1:/home/hoststud/temp/ /root/temp/
------
If a file is not present at the source, but present at the target, you might want to delete the file at the target during rsync.