Wednesday, April 30, 2014

cp, dd, dump, rsync -- diff

I want to back-up some items, and have 3 requirements, plus 3 hopefuls.

1.) Back-up to an ISO, eg to "20141231_bak.iso"
2.) Able to exclude some directories from the process.
3.) Fast
4.) If possible, backup an unmounted partition to avoid any "live acquisition" write errors
5.) If possible, update the ISO with file changes.
6.) If possible, prior to, or following backup, an app which locates duplicate files.

cp solution

For a mounted partition, cp is a reasonable option. We can take an entire data directory, say /home/foo, and safely back it up to an external HDD with a date. We would have to cycle the dumps, since there will be no indexes of changed files.
$ cp -a /home/foo/. /dev/hdb/20140430
Problem: again, slow. Doesn't write to a file, eg to an ISO. Doesn't allow excluded directories. Only works on mounted drives.

dd solution

We prefer backing-up an unmounted partition since there's no chance of new data being written during the backup -- dd fits this bill. Also it's fast. Thirdly, it does exactly what we want for our format: writes from a device to a file
$ dd if=/dev/hda2/ of=/home/foo/20141231_bak.iso
Problem: No directory exclusion since dd backs-up the entire partition. A second problem with duplicating the entire partition is the image includes all free space on the partition, requiring equivalent backup space to the partition. Solution: possibly use "conv=sparse" option to exclude blank space. This means, prior to backups, using something like zerofree to rapidly zero unallocated areas on the partion.

rsync solution

Rsync is not so fast the first time it's run, but subsequent incremental back-ups can be fast, and delta transfer (-W flag) may increase speed even on a USB (as opposed to network) backup. Problem: It's live acquisition; disk must be mounted. It doesn't natively write to a file.

No comments: