Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] rsync vs dd [was Tlug Digest, Vol 14, Issue 23]



Stephen J. Turnbull wrote:
[(rsync based) backup]
  More important is that you don't want to
copy something like /dev/random or /dev/zero, which never return EOF.

I think any sane backup utility will copy the files under /dev in a sane way, as special files See [1] for example with tar.

Rsync will skip these files [2], unless you use the --devices option [3, need to be super-user/root]. Rsynx also takes the option --specials for copying things likes fifos and sockets. (-D is the same as "--specials --devices").

Good old copy with cp on the other hand will try to read the devices and write the content to new files, and thus fail to do what you want.
I really think that rather than try to back up the whole hard drive in
one shot, you should back up /etc, /home, /var, and maybe /usr/local
and /boot. /var should contain your pms state, so you don't really
need /usr, /bin, or /sbin. /proc and /dev you shouldn't touch for the
reasons above.

Whether to backup parts of your installation or all of it in my experince depends a lot on what kind of deployments solutions you have, what kind of restoration needs you expect, and of course budget. But at least in proffesional environments I believe it's best to do complete backups, otherwise you'll too easily end up wondering why you not took backups of that one file you really need now. (Or even worse, your customer wonders why you didn't). But backup is a complex matter, and really need to be done based on your needs.
If you really want to use dd, I would recommend partitioning the HDD
and using dd to write the partitions to files, which can be compressed
and burned to DVD.

Agreed. But remember that if you dd a partition it should preferably be unmounted or mounted read-only, or at least not be written to. Otherwise you'll end up with an inconsistent filesystem on the backup. Except for partitions with very large number of files/ directories I can't see any reason to use dd for "normal" backups.

kind regards,
-sig

[1] Backup of files in /dev with tar

sigurdur@??:/tmp/foo$ tar --create --verbose --file tartest.tar /dev/random /dev/zero /dev/null
tar: Removing leading `/' from member names
/dev/random
/dev/zero
/dev/null
sigurdur@??:/tmp/foo$ tar --list --file tartest.tar
dev/random
dev/zero
dev/null
sigurdur@??:/tmp/foo$


The options to these two tar commands can be shortened to "-cvf" and "-tf". For compression add -z (gzip) or -j (bzip2) to any tar command.

[2] Rsync of files in /dev

sigurdur@??:/tmp/foo$ rsync -av /dev/random /dev/zero /dev/null  .
building file list ... done
skipping non-regular file "null"
skipping non-regular file "random"
skipping non-regular file "zero"

sent 116 bytes  received 20 bytes  272.00 bytes/sec
total size is 0  speedup is 0.00
sigurdur@??:/tmp/foo$

[3] Rsync of files in /dev, with option for rsyncing device files

sigurdur@??:/tmp/foo$ sudo rsync -av --devices /dev/random /dev
/zero /dev/null .
building file list ... done
null
random
zero

sent 97 bytes  received 38 bytes  270.00 bytes/sec
total size is 0  speedup is 0.00

sigurdur@??:/tmp/foo$ ls -l /dev/random /dev/zero /dev/null .
crw-rw-rw- 1 root     root     1, 3 Feb  2 14:04 /dev/null
crw-rw-rw- 1 root     root     1, 8 Feb  2 14:04 /dev/random
crw-rw-rw- 1 root     root     1, 5 Feb  2 14:04 /dev/zero

.:
total 0
crw-rw-rw- 1 root root 1, 3 Feb  2 14:04 null
crw-rw-rw- 1 root root 1, 8 Feb  2 14:04 random
crw-rw-rw- 1 root root 1, 5 Feb  2 14:04 zero
sigurdur@??:/tmp/foo$

--
Sigurd Urdahl
Linux, goofing, cooking, making fire, computer security, having a
beer. Give me good music.



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links