Rsync - markhowellsmead/helpers GitHub Wiki

Copies files from one directory to another, but only those which have changed since the last time the folders were “synchronized”.

rsync -avz [source] [destination]

(a = archive, v = verbose, z compress during transfer.)

Copy all files from FOLDER1 to FOLDER2

If FOLDER2 already exists, it will not be overwritten, but the contents will be updated with any files which have been added to (or modified in) FOLDER1. Don't forget the trailing slash on FOLDER1.

rsync -avz FOLDER1/ FOLDER2

Copy all files and folders, with exceptions

rsync -azvP folder1 folder2 --exclude bower_components

…or with multiple excludes:

rsync -azvP folder1 folder2 --exclude bower_components --exclude node_modules

Copy contents of a subfolder into the parent folder

cd into the parent folder and then execute the following command.

rsync -r SUBFOLDER/* .

Download via SSH

Files will be downloaded:

cd WEBROOT/wp-content/uploads/
rsync -azvP -e 'ssh -i ~/.ssh/KEYFILE' [email protected]:WEBROOT/wp-content/uploads/ . --exclude bower_components --exclude node_modules

or with a pre-installed SSH key and a specific port

rsync -azvP -e 'ssh -p1234' [email protected]:WEBROOT/wp-content/uploads/ . --exclude bower_components --exclude node_modules