Backing up to a remote server
- July 15th, 2007
- By admin
- Write comment
If you aren’t me and/or don’t have a remote server, please move along. There’s nothing to see here. Unless you also would like to backup your files to a remote box or you are me and know that you will forget all of this goodness as soon as it’s done. In that case, read on…
Enable [tag]SSH[/tag] access to the server without having to supply a password:
generate an [tag]RSA[/tag] private key: ssh-keygen -t rsa
copy your public key to the server: scp ~/.ssh/id_rsa.pub user@example.com:~/
ssh to account: ssh user@example.com
append the public key to your authorized keys file and delete the file you uploaded:
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
rm id_rsa.pub
set permissions:
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
You should now be able to ssh into the server without a password.
Run [tag]rsync[/tag]
rsync -avz ~/source/ USER@SERVER:/foo/bar/destination
An [tag]AppleScript[/tag] to run rsync automatically
do shell script “rsync -avz –delete-after ~/source/ USER@SERVER:/foo/bar/destination”
(“delete-after” tells rscync to delete anything on the remote server that no longer exists on your local computer)
Save as “remote_backup.scpt” in /Library/Scripts
Use [tag]iCal[/tag] to run the AppleScript backup:
1. Launch iCal
2. Create a new calendar called “Scripting Cal”
3. Create a new event called “Remote Backup”
4. Set time to run
5. Set the alarm to “run script”
6. A new line will appear, asking you to point to the script you want to use. Navigate to “remote_backup.scpt” and click “select”
7. Set it to run 1 minute before the event
8. Set the event to repeat daily











