rsync is a free software computer program for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction.
rsync can copy or display directory contents and copy files, optionally using compression and recursion.
rsyncd, the rsync protocol daemon, uses the default TCP port of 873. rsync can also be used to synchronize local directories, or via a remote shell such as RSH or SSH. In the latter case, the rsync client executable must be installed on both the local and the remote host.
rsync source destination
A few real life examples are:
rsync -vrplogDtH /old/usr/local/apache/conf /usr/local/apache
That will sync the /old/usr/local/apache/conf/ directorty to the /usr/local/apache/conf/ directory on the same server. If you want to use rsync to go between servers then use the following:
rsync -ave ssh root@192.168.0.1:/backup/ /backup/
That will take the backup directory on 192.168.0.1 and copy it to the server the command is run from. The command will also accept a remote destination if you adjust the command line accordingly.
rsync -avz -e "ssh -p 1658" /oldhome root@207.150.180.18:/oldhome/backup from old server
*************************************************************************************************
below is the working one
rsync -ave 'ssh -p 65321' /oldhome/user root@69.72.221.138:/home/
rsync -pave ssh /home/user/ root@69.72.221.138:/home/user/
this p is for the permission
*************************************************************************************************
this will find the user are having name 32399 and replace this with test.
find . -user 32399 | xargs chown test
this will find the group that are having name 32400 and replace this with test. Please note that this will change only the group name
find . -group 32400 | xargs chown test:test
*************************************************************************************************
script for synchronizing accounts from old server to new server.
#bash
for i in `cat /root/file_rsync`;
do
rsync -pave 'ssh -p 65321' /home/$i/ root@69.72.221.138:/home/$i/
done