User Tools

Site Tools


howtos:backup_a_partition_with_dd_and_gzip

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

howtos:backup_a_partition_with_dd_and_gzip [d/m/Y H:i] (current)
Line 1: Line 1:
 +====== Pre-Backup ======
  
 +If you want to increase the gzip capability you would like to fill the non-allocated space with zeros. This is done by putting zeros into a file until the file fills up all space on the drive. Then delete the file to free up space. Now you should have "​stuffed"​ the free space with good compression zeros:
 +
 +<​code>​
 +dd if=/​dev/​zero of=/​media/​mounted-partition-to-backup/​delete.me bs=8M; rm delete.me
 +</​code>​
 +
 +====== Backup ======
 +
 +When I need to backup a parititon I use the dd command, so simple and so powerful. Usually a partition isn't filled out and have some free space. To avoid creating a unnecessary huge backup file I parse it through gzip:
 +
 +<​code>​
 +
 +root@tdd-HP-ProBook-5310m:/​media/​disk#​ dd if=/​dev/​sda4 bs=64K | gzip -c  > ./​HP_TOOLS.img.gz
 +32688+0 records in
 +32688+0 records out
 +2142240768 bytes (2,1 GB) copied, 68,0337 s, 31,5 MB/s
 +root@tdd-HP-ProBook-5310m:/​media/​disk#​ ls -lh
 +total 268M
 +-rw-r--r-- 1 root root 268M 2011-04-03 15:56 HP_TOOLS.img.gz
 +root@tdd-HP-ProBook-5310m:/​media/​disk# ​
 +
 +</​code>​
 +
 +As you can see 2GB becomes a 268MB backup file.
 +
 +====== Restore ======
 +
 +To restore the backup simply parse the backup file like this:
 +
 +<​code>​
 +
 +gunzip -c HP_TOOLS.img.gz | dd of=/​dev/​sda4 bs=64K ​
 +
 +</​code>​
howtos/backup_a_partition_with_dd_and_gzip.txt · Last modified: d/m/Y H:i (external edit)