Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am currently running a script in leopard every few days to make sure I have backed up my data on a remote server using:

#!/bin/bash
rsync -avvz ~/Documents ~/Workspace -e ssh admin@myhost.com:~/Backup/

There are limitations to this method i.e. I can't look at files that have been deleted a few backups ago. What is the best way to automate this process?

share|improve this question

migrated from stackoverflow.com Aug 29 '09 at 7:50

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 1 down vote accepted

Can you set up a cron job in leopard?

The example rsync options (-avvz) don't delete files in the 'remote' directory which have been removed from the local directory since an earlier backup. They should still be in the remote directory.

But your example is confusing: are you copying files from ~/Documents to ~/Workspace or to ~/Backup/ on myhost.com

This may be a peculiarity of leopard, but it looks like you're just copying from ~/Documents to ~/Workspace in which case the rest of the line might be ignored (and you don't need to invoke ssh)

You should also consider ending the source directory specification with a /

I would agree with Peter that rotating backups are good — if you have the available disk space.

share|improve this answer
1  
Also, if you are using the Apple-supplied rsync (in /usr/bin) and the remote rsync supports it, you should consider adding the -E option to copy extended attributes, resource forks, and ACLs. See the Leopard rsync man page. –  Ned Deily Aug 29 '09 at 7:25

I have found the package rsnapshot to be very good, available in all the distros and i've just now installed it on my mac.

It's a wrapper for rsync that takes care of incremental backups including hourly, daily, weekly and monthly.

share|improve this answer
    
rsnapshot also uses links so that files that haven't changed appear in every backup but only use disk space once. –  Martin Beckett Sep 21 '09 at 17:53

I find time machine very effective, combined with rotating the backups off-site. This isn't `using a remote server', but thought I should just point it out.

share|improve this answer

You're looking for rdiff-backup. It is very, very good.

share|improve this answer
    
+1 — "rdiff-backup backs up one directory to another, possibly over a network. The target directory ends up a copy of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup." –  The Tentacle Aug 29 '09 at 8:08

I run this cron job every day at 5:30 AM:

#! /bin/bash
echo -n "cleaning remote database...";
ssh wf ./bin/mysql-clean;
echo "Done";
echo -n "running remote backup script...";
ssh wf ./bin/mysql-backup;
echo "Done";
scp wf:~/mysql-`date +%Y-%m-%d`.sql.bz2 /storage/mysql/;

Then on my webhost, I have a script called mysql-clean which vacuums my database and removes all cruft. mysql-backup is basically just mysqldump piped through bzip2, then names it according to the date. I also have a script that takes the latest backup file, unzips it, clears the local mysql database, then inserts all data from the backup file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.