Rsync

From My Wiki
Jump to navigation Jump to search

Remote Server

Download

Using port 22:

rsync -avHe ssh user@server:/path/to/file  /home/user/path/to/file

Using an alternate SSH port:

rsync -avHPe "ssh -p$port#" user@server:/path/to/file  /home/user/path/to/file

Using a key file:

rsync -avHPe "ssh -i /full/path/to/keyfile" user@server:/path/to/file  /home/user/path/to/file

Upload

Using port 22:

rsync -avH /home/user/path/to/file -e ssh user@server:/path/to/file

Using an alternate SSH port:

rsync -avHPe "ssh -p$port#" /source/myDir/ user@server:/new/otherDir/

Local Directory

Copy directory's contents to another directory:

rsync -avH /source/myDir/ /new/anotherDir/

Copy another directory itself into another directory:

rsync -avH /source/myDir /new/

For copying without overwriting (test this)

rsync -avH --ignore-existing /source/dir/ /destination/dir/