Montag, 25. Januar 2016

rsync: Sync Two Folders via SSH in Both Directions

After started writing about rsync from local to live. Here's a post about syncing in two directions.

Helpful in rsync is, that also the permissions- and owner information is transfered ("-a" parameter). The "--progress" parameter shows the progress and "--exclude" allows to exclude directories. Be carefully about "--delete". Mind hidden folders like ".git" and ".vagrant" etc.

SSH session on local system (developer desktop) to sync files from (stage/live) server to local system

Here we assume you are in a ssh session on your local development environment and you want to sync from the stage/live server to your local development environment.
rsync -a source/ destination-host:/destination-directory/
Example:

rsync -a --progress www/ --exclude=sites/default/files/ --exclude=.idea/ --exclude=.vagrant/ --exclude=provisioning/ --exclude=.git ssh-username@host.com:/srv/www/destination-folder/

From (stage/live) server to local system (developer desktop)

Here we assume you are in a ssh session on your stage/live server and you want to sync from your local development environment to stage/live server.

Example:
rsync -chavzP --stats --progress username@host.com:/srv/www/some-folder/ /var/www/some-folder/

explainshell.com 

Detailed explanation for the commands can be found at explainshell.com. The rsync command above is explained here.

Happy syncing.


Keine Kommentare:

Kommentar veröffentlichen