Using Rsync to Copy Remote Files to Local Machine on OS X / Linux

The following is used to copy files from a remote server to your local machine using Rsync to keep both synchronized. This is useful for things like backing up important directories on your web server to your external hard drive or elsewhere.

Rsync can incrementally synchronize files between two locations whether local or remote. This means only the updated files on your remote server are updated on your local machine.

From here on in I assume you’re using OS X but this should work on Linux as well. Press CMD+Space to open a Terminal (I use TotalTerminal.) At the command prompt, just use the following:

#!/bin/sh
rsync -a -e "ssh" --rsync-path="sudo rsync -vau " remoteusername@remote.host.com:/home .
rsync -a -e "ssh" --rsync-path="sudo rsync -vau " remoteusername@remote.host.com:/var .
rsync -a -e "ssh" --rsync-path="sudo rsync -vau " remoteusername@remote.host.com:/etc .

This will copy /home, /var, and /etc from your remote machine to the current directory.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>