Re: Using DD To Back Up Debian
Best I can tell, the issue with the original dd command is that you're
referencing the device you want the image saved to by its device name,
not its mount point.
You probably want to mount /dev/sdb1 somewhere on your directory
tree(/media/sdb1 is a common choice) and then set the of argument in
the dd command to
mount/point/path/to/file/file.img
or assuming the destination drive is sdb1 mounted under /media:
/media/sdb1/path/to/file.img
Also, while it's probably not as big a deal since the dinosaur you're
running Debian on only has a 4GB drive, you might want to consider
using partimage instead of dd. dd can create images of whole drives,
and copies every bit from the source, including whatever data is in
the free space, so it's great for making images that can be written to
a blank drive to immediately have a fully configured system once the
write is done or creating a backup for doing file recovery/forensics,
but creating or writing and image can be rather time consuming, and dd
doesn't support compression, so the image files end up being huge. By
comparison, I believe Partimage can only make images of individual
partitions and only copies the actual files, so its a less complete
backup, but it also saves a lot of time(my installed system uses up
less than a Gigabyte of my 300GB system partition, partimage can make
or restore a backup in about 2 minutes, it takes longer to boot into
my live environment or back into my installed system than it does to
do the backup or restore, dd would take hours). Plus, partimage can
automatically compress/decompress the image using either gzip or
bzip2. The backup I made of my installed system last night is 215 MB,
if I used dd, the raw image would be 300 GB, and unless I went to the
effort to zero out the freesppace on my drive before making a backup,
I wouldn't get nearly as good a compression ratio when I compres dd's
output...
Here's a script I wrote to automate partimage. it takes two command
line options, the first a -b or -r to pick between backup and restore,
the second the image file to use. The script does an apt update and
installs partimage if it isn't already installed, then uses some if
statements to pick between the command to make a backup or the command
to restore a backup... As written, it does assume the root partition
is /dev/sda2... I have another, nearly identical script I use for
backing up my Raspberry Pi that assumes /dev/sde2 as the partition to
be backd up or restored as sde is what the microSD slot on my
multicard reader defaults to with my harddrive configuration).
#! /bin/bash
sudo apt update
sudo apt install -y partimage
if [ "$1" == "-b" ]
then
sudo partimage -z2 -b -o -d save /dev/sda2 $2
fi
if [ "$1" == "-r" ]
then
sudo partimage -b restore /dev/sda2 $2
fi
Reply to: