Skip to main content

RSYNC to update files between old and new server?

Comments

4 comments

  • cPanelLauren
    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
    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)
    Some other options you may want to look at using depending on your situation:
    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
  • Arkaic
    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@***.***.***.**:/home
    0
  • AzeDK
    @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
  • cPRex Jurassic Moderator
    @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.