Archive for December, 2006

Rsync: Website Backups Made Easy

Saturday, December 23rd, 2006

Greg has been persistently encouraging me to post in this space a few of the useful technical tidbits I have figured out over the years. So, for those who might find it interesting, here is a simple rsync flashcard I made some time ago when I was doing a bit of Sys-op work on our (currently hibernating) website, Music For Dozens.

If you ever want to backup your website (or any other internet-accessible files), and assuming you have access to the UNIX command line shell on the host machine, rsync is the way to go. According to it’s homepage, rsync is “an open source utility that provides fast incremental file transfer.” In other words, it is the perfect tool for quickly copying a large number of files from one place to another. It can tunnel its data through ssh, which is generally considered de rigueur for security on the net, and is quite fast (particularly when making backups, as it only [incrementally] transfers the data that has changed since the last transfer).

To use rsync, you will need to log in to the machine you are trying to preserve (preferably using ssh for safety’s sake). Then, type something like this:

rsync -avz -e ssh relative/path/to/dir user@11.11.11.111:/remote/target/folder

When typing this UNIX incantation to invoke rsync, you will need to have at hand

  • the location of the files or folders you want to send [indicated here as “relative/path/to/dir”],
  • your backup machine’s IP address (or domain name [for example: “11.11.11.111”]),
  • a user account name on that machine [“user”],
  • the appropriate password (which rsync will ask you in a few seconds after you hit “return”, assuming you do not have some better way of making the two computers trust each other over ssh),
  • and the full path of where you want to put the backup files [“/remote/target/folder”].

(Replace the information in [brackets] with the real stuff or you will be out of luck!)

Remember to include that pesky at sign (@) between the remote username and remote machine address, as well as the even-easier-to-overlook colon (:) between that address and the data’s destination path. Also, don’t put any slashes (/) at the end of these locations, even if you are sending folders instead of files (rsync has no trouble with folders; you don’t have to compress the directory with zip or tar before sending it).

Here is the command line template as a (hopefully better annotated) flashcard, fully suitable for framing:

rsync flashcard
(My thanks to Greg for making this image suitable for public distribution and for contributing a good chunk of the explanatory language.)