I need to backup a bunch of directories to my NAS (it basically shows up as a network share in Finder). I don't want to make it bootable, just need to backup a few directories. I'd also like to have it run nightly. I've tried looking at documentation for rsync, but haven't been able to figure it out yet.
I also took a look at rsyncx, but can't get that to install. Don't care about Time Machine support either, just need a simple backup.
Best Answer
Does your NAS have an rsync service set up? Some support it (e.g. ReadyNAS). If so, you can do something like this:
You'll need to change DEST to the IP address of your NAS, and change paths and stuff to suit.
If you save that as, say,
~/bin/backup.sh
(and be sure to dochmod a+x ~/bin/backup.sh
) then you can run it nighly using cron. Runcrontab -e
and add this line:(
0 0 * * *
means: run at midnight every day, every month. First column is minutes, so 3am is0 3 * * *
. This will write logs in~/logs
so make sure that directory exists, or put them somewhere else)If your NAS doesn't support rsync as a service then I think it should work if you change the start to this:
and at the end:
(if your share is open, you can leave off user and password)
If you want timestamped backups, you can experiment with the date command. e.g.
then access $DATE in your script.
If anything here isn't clear to you, just ask.