Rsync Backup

From DreamHost
Revision as of 02:37, 17 April 2012 by Nbarth (Talk | contribs)

Jump to: navigation, search

It's possible to backup your DreamHost account using rsync. You may want to mirror your website locally for whatever purposes. This is not a particularly user friendly approach: you will require a certain amount of technical knowledge.

In order to use rsync, you must have shell access to your DreamHost account. You must also have OpenSSH and rsync installed on your local machine. These software packages are included with most Linux distributions, and are available to Windows users via cygwin.

Simple rsync Backup

To synchronise your DreamHost account with a local directory, execute this command from your shell:

rsync -e ssh -av username@server.dreamhost.com:remote_directory local_directory
  • username is your shell username.
  • server is the name of the machine which hosts your shell account. (eg. jezebel, cortes, etc.)
  • remote_directory is the directory on the server you wish to backup (i.e., the source). This is relative to your home directory.
  • local_directory is the local directory in which the backup should be made (i.e., the destination).

For example, the following command would backup the www directory of the example.com account to a local directory backup, assuming a user called exampleuser:

rsync -e ssh -av exampleuser@example.com:www/ backup/

rsync will prompt you for your password and then begin downloading your remote directory.

rsync contains plenty of options. Initially, perhaps the best option is -n (i.e., replace -av with -avn in the above example) which just pretends to do the synchonisation but doesn't actually transfer any files. If you're nervous or just trying out different options, -n can make things a little faster and safer. Another option to watch out for is the --exclude option, which is used to exclude certain files or directories from the backup.

First-time users of rsync should familiarize themselves with the "trailing slash" path interpretation. Briefly, a trailing slash on the source means "copy the contents of the directory." No trailing slash means, "copy the directory itself." See USAGE in the rsync(1) man page for more detailed information.

Scheduled or Automated rsync Backups

See Crontab

Automating Personal Backups

Rsync can be used in conjunction with Personal Backups to back up your personal files incrementally, at scheduled times.

Note: Due to the rssh shell used you may get an error about "insecure option -e", the solution is to add --protocol=29 to your rsync command. More information is available here.

Windows solutions include:

  • DeltaCopy
  • CWRSYNC Is a packaging of rsync, ssh client and the required cygwin libraries for Windows. It runs on all versions of Windows.

Other Automated Backups

See Automatic Backup

See also