RSYNC to update files between old and new server?
Hey there!
We're looking to migrate an account which is 2TB to a new server, due to the size of the account it takes approx 6 hours to complete.
We had planned to use the Transfer Tool to migrate the account during the day and then do a final rsync at an off-peak time to catch any latest files or changes that might've been made since the initial Transfer started.
We can take care of MySQL by re-running the Transfer Tool excluding the home directory at the off-peak time before the IP address switch over to ensure database changes are up to date.
Has anybody done something like this before?
What sort of rsync command should we be using to recursively catch and carry over and overwrite if applicable NEW / MODIFIED files within a users /home/*cpanelaccount* directory whilst retaining correct permissions + ownership?
Or any alternative method of replication would be appreciated.
Thanks in advance.
-
This is not unusual for people to do, especially with large accounts. Something like the following may be helpful: rsync -auvH -e "ssh -p $port" /home/cpmove-$username.tar.gz root@$sourceIP:/home/cpmove-$username.tar.gz
Explanation of the flags noted in the table below- -a is the equivalent of using -rlptgoD so I included those flags as well for full disclosure
Some other options you may want to look at using depending on your situation:Flag Fulltext Description [COLOR=rgb(97, 189, 109)]-v [COLOR=rgb(97, 189, 109)]--verbose [COLOR=rgb(97, 189, 109)]Increase verbosity -r --recursive recurse into directories -p --perms preserve permissions -l --links When symlinks are encountered, recreate symlink on the destination -o --owner preserve owner -g --group preserve group -D --devices --specials preserve device files and special files -t --times preserve modification times [COLOR=rgb(97, 189, 109)]-H [COLOR=rgb(97, 189, 109)]--hard-links [COLOR=rgb(97, 189, 109)]this tells rsync to look for hardlinked files in the transfer and link together the corresponding files on the receiving side. Without this option, hard-linked files in the transfer are treated as though they were separate files. -e --rsh=COMMAND specify the remote shell to use (if the remote host is listening on something other than 22) [COLOR=rgb(97, 189, 109)]-a [COLOR=rgb(97, 189, 109)]--archive [COLOR=rgb(97, 189, 109)]archive mode (equivalent to -rlptgoD. This tells rysnc to sync directories recursively, transfer special and block devices, preserve symlinks, modification times, groups, ownership, and perms. [COLOR=rgb(97, 189, 109)]-u [COLOR=rgb(97, 189, 109)]--update [COLOR=rgb(97, 189, 109)]skip files that are newer on the receiver (destination server) Flag Fulltext Description -z --compress This option forces rsync to compress the data as it is sent to the destination machine. Use this option only if the connection to the remote machine is slow. -P --partial --progress When this is used rsync shows a progress bar during the transfer and keeps the partially transferred files. Useful for transferring large files over a slow or unstable network connection. 0 -
SNIPPED
Hi @cPanelLauren, that's great, thank you! So if I'm doing the entire directory rather than the .tar.gz file I could use the following on the *existing* server to push it to the new one for example? rsync -auvH /home/cpanelaccount root@***.***.***.**:/home0 -
@cPanelLauren Shouldn't it be "DestinationIP" instead of "SourceIP" ? rsync -auvH -e "ssh -p $port" /home/cpmove-$username.tar.gz root@$sourceIP:/home/cpmove-$username.tar.gz
0 -
@AzeDK Here's the examples I always provide for rsync, with various possibilities: From a remote server to the local server: rsync -avh root@remoteip:/path/on/remote/server /path/on/local/server
If you need to use a custom SSH port:rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/
From a local server to a remote server:rsync -avh /full/path/to/directory username@remoteip:/destination/directory/on/remote/server
Following those examples, Lauren's is correct for the example she was providing, as that matches my custom port example as well.0
Please sign in to leave a comment.
Comments
4 comments