Transferring Files From and To a Remote Server Using rsync

Transferring Files From and To a Remote Server Using rsync

 

Here are a few useful commands that you could use when transferring files from one server to another.

From source server to destination:

  • With a default SSH port:

 rsync -vHaxx [email protected]:/home/user/dir/
  • With a special SSH port:

rsync -avz -e 'ssh -p 2510' [email protected]:/home/user/dir/

 


Reverse rsync, syncing files form a remote server to local.

  • With a default SSH port:

rsync -vHaxx [email protected]:/home/user/dir/ /home/user/local-dir/
  • With a special SSH port:

rsync -avz -e 'ssh -p 2510' [email protected]:/home/user/dir/ /home/user/local-dir/

Also if you would like to transfer only the missing files you could use the --ignore-existing flag. This is very useful for final sync in order to ensure that there are no missing files after a website or a server migration.

Basically the commands would be the same apart from the appended --ignore-existing flag.

From source server to destination:

  • With a default SSH port:

 rsync -vHaxx --ignore-existing  [email protected]:/home/user/dir/
  • With a special SSH port:

rsync -avz -e 'ssh -p 2510' --ignore-existing [email protected]:/home/user/dir/

 


Reverse rsync, syncing files form a remote server to local.

  • With a default SSH port:

rsync -vHaxx --ignore-existing [email protected]:/home/user/dir/ /home/user/local-dir/
  • With a special SSH port:

rsync -avz -e 'ssh -p 2510' --ignore-existing [email protected]:/home/user/dir/ /home/user/local-dir/

Hope that this helps.

Coffee For Me