08 Oct 2009 @ 11:57 AM 

DD has always worked great for me. If you have similar partitions and fs then you can backup and restore to it. You might run into problems if you had a 10gig partition on sda ext2 and then you try and restore it later to sdb5 ext3 or something like that ? Anyway, some backup is better than no backup. I’m using a ext4 fs and backing my whole disk up to a “dump” using the dd command. Later I might opt to backing up to a partition so i can have a mirror image, but for now this is good.

I use gnu screen because the backups take forever, this way i can detach and go do other stuff.

zonemikel@GalacticAC:/mnt/sda1$ sudo fdisk -l
 
Disk /dev/sda: 164.6 GB, 164696555520 bytes
255 heads, 63 sectors/track, 20023 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9eb99eb9
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1275    10241406   83  Linux        <----- backing up to here for now
/dev/sda2            1276        2550    10241437+  83  Linux
/dev/sda3            2551        2677     1020127+  82  Linux swap / Solaris
/dev/sda4            2678       20023   139331745   83  Linux
 
Disk /dev/sdb: 20.0 GB, 20020396032 bytes
255 heads, 63 sectors/track, 2434 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x8f670ed7
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2403    19302066   8e  Linux LVM         <------------- Root partition
/dev/sdb2            2404        2434      249007+   5  Extended
/dev/sdb5            2404        2434      248976   83  Linux
zonemikel@GalacticAC:/mnt/sda1$ screen sudo dd if=/dev/sdb1 of=/mnt/sda1/ubuntu_dump_Oct_08_09.dump bs=64M

After i detached i went to see if the file was growing and it indeed was.

zonemikel@GalacticAC:/mnt/sda1$ ls -l
total 426216
drwx------ 2 root root     16384 2009-09-06 18:22 lost+found
-rw-r--r-- 1 root root 436428800 2009-10-08 11:51 ubuntu_dump_Oct_08_09.dump
zonemikel@GalacticAC:/mnt/sda1$ ls -l
total 5373972
drwx------ 2 root root      16384 2009-09-06 18:22 lost+found
-rw-r--r-- 1 root root 5502926848 2009-10-08 11:56 ubuntu_dump_Oct_08_09.dump
zonemikel@GalacticAC:/mnt/sda1$ ls -l
total 5628820
drwx------ 2 root root      16384 2009-09-06 18:22 lost+found
-rw-r--r-- 1 root root 5763891200 2009-10-08 11:56 ubuntu_dump_Oct_08_09.dump
zonemikel@GalacticAC:/mnt/sda1$

and if i ever wanted to restore

sudo dd if=/mnt/sda1/ubuntu_dump_Oct_08_09.dump of=/dev/sdb1 bs=64M

UPDATE:
Well this has saved me a bunch of times, I’m wanting to add this info here so I dont forget it.

Adding noerror makes it so dd wont stop if there is a error it will just fill the places it cant read with zero’s (thats the sync option) and continue on.
The “&” at the end makes it so it runs in the background, this way you can do whatever you want and it will finish when it finishes. It then shows you the process id and gives you another prompt.

zonemikel@GalacticAC:/mnt$ sudo dd if=/dev/sda1 of=/mnt/sdb1/ub_9.10_11.24.09.dump bs=512 conv=noerror,sync&
[1] 3530
zonemikel@GalacticAC:/mnt$

If you want to see the speed/progress of the dd command it sounds weird but you have to send it this kill command. You send it to the proc id that we found above or by “ps aux | grep dd”

zonemikel@GalacticAC:/mnt$ sudo kill -USR1 3530
zonemikel@GalacticAC:/mnt$ 5024233+0 records in
5024233+0 records out
2572407296 bytes (2.6 GB) copied, 376.458 s, 6.8 MB/s

Then if you want to restore someday. The notrunc tells dd to continue until /dev/sda1 is full and noerror is the same as before.

# dd if=/mnt/sdb1/ub_9.10_11.24.09.dump of=/dev/sda1 conv=notrunc,noerror
Posted By: admin
Last Edit: 24 Nov 2009 @ 11:54 AM

EmailPermalink
Tags
Categories: Linux


 

Responses to this post » (2 Total)

 
  1. admin says:

    For those observant enough you will note my root has 19302066 1K blocks and the place where i was copying the dump was 10241406 1K blocks so i was trying to put 19 gigs into 10 gigs …. it stopped when the dest drive was full. Ill have to repartition the drive and make sure it has enough space.

  2. admin says:

    This really just saved me. The after a “update” i restarted my server … it would not even boot something about grub error 22. After about a day of trying to wrap my head around lvm and such i ended up reinstalling ubuntu. None the less my backup allowed me to restore everything to the way it was in just a few hours.

    I opt not to do that “lvm” thing, you cant mount the drive from a rescue disk. Its really dumb to have the OS default to install something that you cant even access from the rescue disk. Also grub cant really install to a lvm disk, or at least i had hell with it. Stick to the basics . . .

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Change Theme...
  • Users » 5
  • Posts/Pages » 71
  • Comments » 62
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Contact Me



    No Child Pages.

Front



    No Child Pages.