can be used to create a bit-by-bit image of a partition or an entire hard drive. If you restore such a backup to another drive/partition, it will be an exact
copy of the original. If the original partition was bootable, the restored copy will be as well.
In general, people don't use dd
for regular backup jobs. There are a number of reasons for this, such as these:
- dd can only relate to the block device, not the filesystem contained therein. It copies the entire drive/partition, not just the parts containing actual data. The backup will take longer than it needs to, and will also contain all the unused parts of the drive/partition.
- It's not possible to use dd to back up a partition or drive containing an active filesystem, if that filesystem is mounted read/write. As dd works its way form the beginning to the end of the drive/partition, the filesystem will be subject to changes and the copy will be inconsistent.
You can sort-of work around problem #1 by piping the data from dd
through a compressor like gzip
, but as time goes by, the drive/partition will contain an increasing amount of fragments from deleted/temporary files. This negatively affect your ability to compress the unused parts.
(Exception: If your drive is an SSD and the kernel sends "trim" commands to it whenever a file is deleted, the drive will usually just return zeroes if one tries to read a "free" block, and a block of zeroes will compress really well.)
The second issue affects every backup utility, not just dd
. The only really good way to eliminate the problem is to dismount the filesystem or at least remount it as read-only (which obviously isn't an option for the root filesystem), or back up a read-only snapshot (requires LVM). Using snapshots means you can
use the system while a backup is being performed, although you may experience slightly lower performance/responsiveness than usual.
You're probably better off using a generic backup tool rather than relying on dd
. If you use something simple like tar
but also create a small backup of the partition table (and you can certainly use dd
to do this), it should be possible to restore the entire system to a bootable state from, say, a live CD/DVD/USB stick.