You could also try e2image:
The e2image program will save critical ext2, ext3, or ext4 filesystem metadata located on device to a file.
Despite that by default e2image saves metadata only, it's able to save data too, by the use of -a option. (See section "Including data" by the link)
The -a option can be specified to include all data. This will give an image that is suitable to use to clone the entire FS or for backup purposes. Note that this option only works with the raw or QCOW2 formats.
QCOW2 format is more preferable for backups than raw format. QCOW2 image is a normal file with size that is close to used space of partition to back up. Raw image is a sparse file with all the implications - tools that don't handle sparse files specifically will process not only used space, but free space too.
So, usage examples are:
- Backup
sda1partition, including files & metadata, to the fileboot-part.qcow2:
sudo mount -o remount,ro /dev/sda1 sudo e2image -a -Q /dev/sda1 boot-part.qcow2 Note that remounting as read-only is required to guarantee that no one will write to the partition, while backup is in progress. After all, you are able to remount as read-write by sudo mount -o remount,rw /dev/sda1 if you need to.
- Restore partition
/dev/sda1from QCOW2 image fileboot-part.qcow2:
sudo umount /dev/sda1 sudo e2image -r boot-part.qcow2 /dev/sdd1sda1 Note that umount is a must since you can't rewrite superblocks of a mounted partition. If /dev/sda1 is not mounted that time, you can skip this step. :)
It's also worth noting that in restoring scenario size of /dev/sda1 should be equal or greater than partition inside image file, otherwise you will get error: e2image: Invalid argument while trying to convert qcow2 image (boot-part.qcow2) into raw image (/dev/sda1).