|
|
A script to prevent damage from rm -rf malware
You don't need that script. You can do it with the built-in rsync command rather easily:
This creates a hard-link tree under /backup/path/for/home pointing at $HOME, just as the overly-complicated Perl script also accomplishes, presuming that /backup/path/for/home and $HOME are on the same disk.
Better than mere rsync...
If you're a die-hard UNIX head, there's a fantastic bit of python scriptwork called rdiff-backup. Why do I make the "die-hard UNIX head" proviso? There's a bit of console work and compiling to do if you want to install this. Adventurous non-UNIX people are welcome to try it out (learn something new)! I'd be happy to help, if you're interested. Once's it's installed it's easier than easy to use: $ rdiff-backup /Users /Path/to/other/directory/Users It's like rsync in that it keeps a mirror of whatever directory you tell it to backup, but it also keeps "diffs" of the changes, like an incremental backup. I have an NFS server in my basement, and I have a cron job backing up the /Users folder every night, for each of my Macs. I can also have it remove the incrementals older than 21 days (any time amount is possible). It has backup and restore capabilities. I used to back up to an old tape drive, but with disk space so cheap, it's easier and cheaper to just use disks. I can restore to an earlier version of a file if something happens. I haven't tried to mirror a whole disk, so I don't know if such a thing were bootable, but I imagine it wouldn't be hard to make it so. Long story short, the only sure way to protect against file deletions is to keep backups. I have a .Mac account, but find that Apple's Backup utility doesn't do it for me. I like having incremental backups and a live mirror on a hard disk, networked or otherwise. Note: (It's necessary for the destination folder to exist before running the script and it's useful to have the same name and permissions as the source, eg. /Users permissions are drwxrwxr-t (1775 in Octal), so you would want /Path/to/other/directory/Users [just the Users folder] to have the same permissions. This would make a full restore as easy as just clicking and dragging or a cp -Rp). 2nd Note: If anyone is interested in helping me, I think it would be rather easy to make an AppleScript wrapper for this, where backups and restores and such would become more accessible to Joe User. Let me know. ---
A script to prevent damage from rm -rf malware
Wouldn't you need the -R flag to preserve structure ? or is that implied in -a (archive mode) ?
rsync doesn't work that way.
Hi,
A script to prevent damage from rm -rf malware
The example rsync command line by merlin contains an error. Try this: rsync -a --delete --link-dest=$HOME $HOME/ /backup/path/for/home Note the trailing slash '/' on $HOME/. Without it rsync creates /backup/path/for/home/X/*, where X is the name of your home directory, and rsync then can not match up paths correctly between the backup directory and the link-dest directory. With the trailing slash rsync creates /backup/path/for/home/* and --link-dest works as expected. Also, the stock rsync that comes with OS X does not copy the resource fork of HFS+ files. So backups of HFS+ directories created using it can not really be called backups. Install and use the resource fork aware version of rsync, aka rsyncx from versiontracker (http://www.versiontracker.com/dyn/moreinfo/macosx/16814).
rsync still doesn't work
I did as you mentioned, adding the /, same result. New inodes. It makes a backup just fine, but not using links.
sweet.
I think that is a very cool script. Nice job. Very elegant--exploiting the fact that deleting a file doesn't really delete the file. I love it. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.07 seconds |
|