Another useful command that is related to file system backups is the dd command. The abbreviation stands for convert and copy (cc), but because cc was already some other command (the C compiler), the name of the utility became dd.The purpose of dd is to convert and copy files byte by byte. The command is written to get its input from the STDIN and write its output to the STDOUT, but by using the arguments if (input file) and of (output file), you can use it to copy files from and to anywhere. The dd command distinguishes itself from other commands such as copy in that it can work bytewise. With dd it is possible to specify exactly what bytes you want to copy, but you can use it as well to copy complete files. For example, dd if=/etc/hosts of=/root/computers would just copy the /etc/hosts command to a new name. Of course, you wouldn't use dd for that, because cp can also do it and can do it in a much easier way. However, something that cp can't do is dd if=/dev/sda of= /dev/sdb, which would make a byte-by-byte image of /dev/sda and copy that to /dev/sdb.
If you want to use dd to make a backup, that's possible as well. It works especially well to create a backup of an entire device or a part of the device. For example, use dd if=/dev/sda1 of=/media/ someserver/sdal.bakup to make a backup of a complete partition. Also useful is the option to write a backup of an important area on your hard disk. For example, use dd if=/dev/sda of=/boot/mbr. backup bs=512 count=1 to make a backup of the master boot record of your first SCSI hard drive; this backup needs to be one block of 512 bytes only, because the master boot record is no bigger than that. Another thing dd can do is write an image of a CD to a file: dd if=/dev/cdrom of=/cdrom. iso. Once this image is created, you can even mount it with mount -t iso9660 -o loop /cdrom.ido /mnt and work with it like you are used to working with a regular CD.
Was this article helpful?