Ah well, not actual requirements, more like a ‘best used with’.
And.. some basic unix knowledge like ~ = your home directory and stuff like that.
After enabling the backups user:
Generate an ssh key
First, launch the terminal app ( cmd+space and type terminal ) and type( > indicates the beginning of the prompt ):
> cd ~/.ssh ; ssh-keygen -t rsa
It’ll ask for a destination, just use the default ( ~/.ssh/id_rsa.pub ), and a passphrase ( leave it blank ).
Now that we have the ssh key we need to publish it to the remote server, since the dreamhost backup server doesn’t allow ssh we’re gonna have to copy it using scp, but first we’re gonna establish a secure ftp session in order to create a couple of directories we need.
Again in the terminal:
> sftp email@example.com ; mkdir ~/.ssh ~/backupdir
Replace ‘username’ with your dreamhost backups user and ‘backupdir’ with something that’ll identify to which machine that backup belongs, you’ll be asked to type in the password dreamhost mailed you.
Now, I’m assuming you don’t have already published any ssh keys to that server, so, getting back to the terminal:
> scp ~/-ssh/id_rsa.pub firstname.lastname@example.org:~/.ssh/authorized_keys
Again, replace ‘username’ with yours and type in your password for the last time.
In case you already have an ‘authorized_keys’ file on the server( like if you’re adding multiple machines ) you’ll need to append the current machine ssh key to the authorized_keys file but since Dreamhost doesn’t allow ssh to the backup server you’ll have to download it and upload it after you’re finished.
> scp email@example.com:~/.ssh/authorized_keys ~/Desktop/
> cat ~/.ssh/id_rsa.pub >> ~/Desktop/authorized_keys
> scp ~/Desktop/authorized_keys firstname.lastname@example.org:~/.ssh/authorized_keys
Great, we’re done here, no need to type in your pass whenever you want to ssh/rsync/sftp/scp to your server from that machine.
Scheduling and Actual Backup Magic
First, download this automator workflow, what it does:
clears the previous backup log ( /tmp/dh-rsync-backup.txt )
starts the sync process and saves the log to the above file
sends out a growl notification when finished
kills any lost rsync process ( just to be sure)
On the last line you’ll need to:
replace USERNAME by your backup username
replace BACKUPDIRECTORY with the name of the dir you created before
Optionally, you can edit the –exclude rules and directories to backup, remove or add new ones, remember, the directory paths are relative to your home directory, don’t forget to add a ” \ ” before moving down a line and use single quotation marks for paths with spaces( ‘Library\Application Support’ ).
Now go to File > Save As > change the file format from workflow to application, save the “dh-rsync-backup.app” in a safe place, I have it in ~/Documents/Automator Workflows/.
Now, you can manually run that .app whenever you want to start the backup process, but that isn’t practical, so let’s schedule its execution in a nice clean way with iCal.
Add a new Calendar to iCal
Add New Event
Recover a Backup
rsync -avP USERNAME@backup.dreamhost.com:~/BACKUPDIR /LOCALDIR
Use this post as inspiration/reference for your own solution.
Here’s a simplified script:
protocol 29 --delete --force --delete-after --delete-excluded \ ~ USERNAME@backup.dreamhost.com:~/BACKUPDIR
‘–protocol 29′ is needed to remove the implicit -e parameter used by newer versions of rsync, type rsync on the terminal to check out the other parameters. ( I think –delete and –delete-after creates some redundancy but am not sure, heh )
And other useful posts: