1

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 [email protected]:~/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?

5 Answers 5

1

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.

1
  • 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, 2009 at 7:25
3

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

1
  • +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." Aug 29, 2009 at 8:08
3

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.

1
  • rsnapshot also uses links so that files that haven't changed appear in every backup but only use disk space once. Sep 21, 2009 at 17:53
1

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .