Home Profile Projects Articles

MacOSX: Creating a hard drive backup image

Thursday, 13 of December , 2007 at 12:32 pm

Recently, I have been having a lot of problems with my MacOSX machine at work. The machine contains multiple partitions each of which contains a separate server environment. Up to now, I haven’t been backing-up these partitions. This is a real pain when something goes wrong (like today) because it takes a day to re-configure a server on any given partition.

Anyways, to stop future pain, I’m starting to create compressed images of my partitions.

This is how I created my backups:


  1. Boot-up your system. Note: You can’t boot from the partition you want to backup.

  2. Start up the Terminal.

  3. Find the partition you want backup. You can use the following command:

    $mount
    
    /dev/disk0s9 on / (local, journaled)
    devfs on /dev (local)
    fdesc on /dev (union)
     on /.vol
    /dev/disk1s3 on /Volumes/Server1 (local, journaled)
    /dev/disk0s3 on /Volumes/Server2 (local, journaled)
    /dev/disk1s5 on /Volumes/Server3 (local, journaled)
    /dev/disk0s5 on /Volumes/Server4 (local, journaled)
    /dev/disk0s7 on /Volumes/Server5 (local, journaled)
    /dev/disk0s11 on /Volumes/Server6 (local, journaled)
    /dev/disk0s13 on /Volumes/Server7 (local, journaled)
    /dev/disk0s15 on /Volumes/Server8 (local, journaled)
    automount -nsl [176] on /Network (automounted)
    automount -fstab [180] on /automount/Servers (automounted)
    automount -static [180] on /automount/static (automounted)
    


  4. Unmount the partition/drive you want to backup. You can do this by throwing the partition/drive on the desktop to the trash can.

  5. Next, run the following command where src_name is the drive that you want to backup (ie. disk0s5 ) and dest_name is the drive you want to copy the backup to (ie. Server7)
  6. $sudo dd if=/dev/src_name
           | gzip > /Volumes/dest_name/backup.img.gz
    


If you need to restore the backup, you can run the following command.

$gzip -dc /Volumes/dest_name/backup.img.gz
      | sudo dd of=/dev/src_name

Note: There is probably a Mac tool somewhere that does the same thing if you scared of the command prompt.

Category: Programming

No Comments

No comments yet.

Leave 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> [tex]