Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'hfspax and anacron' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
hfspax and anacron
Authored by: vasi on Dec 19, '01 08:31:12AM
hfspax is a nice utility to archive HFS+ directories without losing resource forks or file attributes. Anacron is available via Fink, it basically runs programs every X days like cron does, except it doesn't depend on your computer always being on at the time the program is set to run.
This will backup your home folder:
cd /Users
hfspax -wx cpio -f /backup/destination myUserName
I like it more than ditto since it puts everything in one file, so I can gzip it after. Also, it lets you filter files. Since I know that all the MP3s in my Sound folder are already burned to CDs, I don't have to back them up:
hfspax -wx cpio -s '|.*/Sound/.*.mp3||' -f /backup/destination.hfspax ~
In case you're wondering, that's just a regex to turn "*/Sound/*.mp3" into an empty string, which tells pax I don't want it to be archived. I can restore by expanding the gzip archive, then running
hfspax -r -pe -f vasi.hfspax
which preserves resource forks, permissions, everything. Another thing I find useful to do when backing up is to run
cd
find -type f -print0 > /some/file
find -type d -print0 > /some/other/file
This gives you a nice list of all the files and directories in your home folder. You can use it to restore the entire directory structure (echo /some/file | xargs -0 mkdir -p), so even the things you filtered out of the hfspax archive still have a place to go when you restore them. You can also use it if you lose just a couple of files and only want to restore those. Just search throught the listing for the files you lost, so you know the exact names, and then use hfspax to extract just them.
I have all this done in a script that runs automatically daily via anacron (does that make it a "zero step backup"? :-). One thing to be careful of when you back up is that you don't overwrite your backup location, like the backup system in this article does; if something goes wrong in the middle of the backup, you could be SOL. Instead, move the old backup, create the new backup, then if and only if that was successful delete the old one.
Hope this helps someone!
vasi

[ Reply to This | # ]
Is anacron what you want here?
Authored by: el bid on Dec 19, '01 04:18:16PM
it basically runs programs every X days like cron does, except it doesn't depend on your computer always being on at the time the program is set to run.


Er, of course this doesn't mean that anacron will run a backup when the computer isn't on... :-)

I don't ever switch computers off, so I'm not entirely clear about the implications, but if I'm guessing right the difference with anacron is that when you switch on it will say: "Heaven's is that the time, I should have run this backup three hours ago", and start backing up right away.

But this probably isn't what you want, is it? You've probably set your backup to run at 3.00am each night when there's a good chance you won't be using the machine -- you don't want backups running while you're actually creating and changing files in your home directory.

My feeling is that cron does a better job here. If it's skipped a backup because the machine was switched off, no big deal. It'll catch up tonight. And it won't suddenly try backing up while you're creating spreadsheets just because it has a pang of guilt.

--
el bid


[ Reply to This | # ]
Yup, it is
Authored by: vasi on Dec 20, '01 01:33:42AM

Anacron actually runs as a cron job; I set it to run every hour. So yeah, it's fairly likely that it will run while I'm using the computer, but since I "nice" the backup command I don't notice a slowdown, just some disk churning.

I don't leave my computer on all the time, partly to save on power and partly cuz the humming bugs me when I sleep. I'd much prefer that anacron really runs the command every day, rather than having cron want to run daily but only really running every week. I've had too many unfortunate accidents to risk my data; a bit of disk churning isn't bad at all.

vasi



[ Reply to This | # ]
Yup, it is
Authored by: el bid on Dec 20, '01 03:16:21AM
but since I "nice" the backup command I don't notice a slowdown

I wasn't raising the issue of resource contention. The point I was making is that it's not a good idea in general to backup files the might be in use. You can't necessarily rely on the integrity of the backup.

--
el bid


[ Reply to This | # ]
hfspax and anacron
Authored by: loren_ryter on Dec 20, '01 12:41:19PM

boy, for those of us who are not unix wonks but aren't totally uncomfortable with typing in the command line and such, a simple step by step or pre-compiled script to backup folder a to location b that can be run with cronotab and retains all you'd expect (resource forks, invisible files, locked files, etc etc) would be so much appreciated....

i hope someone can put this together a new tip!



[ Reply to This | # ]
hfspax and anacron
Authored by: thatch on Dec 20, '01 05:50:12PM

Almost exactly what you want is available from Mike Bombich's OS X Tips site. Check it out. It's listed in the links section here.



[ Reply to This | # ]