Note that this is a simplistic method, that will create large files already for "small" devices.
Backup:
- use e.g.
lsblk -ape7
to find out which /dev/...
you have the USB drive positioned at
(e.g /dev/sdc
to have a true dev to show below).
- make sure the drive is NOT mounted
- Open a terminal, type
sudo dd if=/dev/sdc bs=128k | gzip --best >/place/to/store/backup.img.gz
- hit Enter and fill in the (root) password
Restore:
The example /dev/sdc
needs to be same-size USB drive, or larger than the backup source.
Also: Make sure /dev/sdc
is the CORRECT device,
all earlier content will be lost and will NOT be recoverable.
Enter gzip -c /place/to/store/backup.img.gz | sudo dd of=/dev/sdc bs=128k
in a terminal (at the bash prompt) and provide the requested input (root password).
Additional options to dd
(notrunc, noerror) and gzip
might be in place.
Options:
The image file produced by dd, when uncompressed (and at least of some common content types), may be mounted as a loop device:
lodev=$(losetup -f)
- will create a device, if possible, and keep the name in $lodev
sudo losetup $lodev imagefile
- will attempt to use the imagefile, create a 'removable' disk and mount the partitions in it.
sudo losetup -d $lodev
- will dismount the image, and deconstruct the loop device.