Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Creating a disk image of my server
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Red-Drop
n00b
n00b


Joined: 10 Mar 2005
Posts: 37

PostPosted: Thu Jun 02, 2005 3:22 pm    Post subject: Creating a disk image of my server Reply with quote

Hey all, I have a few of very nice servers running happily around town. Now i want to make them a little more disaster recoverable.

All of the machines are running in a smiliar fashion 2 raided IDE HDD's and a larger backup IDE. The sizes should be irelevant.

What i want to do is create disk images of either the main drives or partition based images so that if the raid compleley f's up or there is some other disaster I can quickly restore an image and have the machines back up and running with the minimum ammount of fuss. IE not performing a full stage 1 gentoo reinstall than confguring all of the services.

What is the best way to go about doing this?
Back to top
View user's profile Send private message
Cadorna
Apprentice
Apprentice


Joined: 30 Dec 2004
Posts: 215
Location: Argentina

PostPosted: Thu Jun 02, 2005 8:37 pm    Post subject: Reply with quote

Code:

dd if=/dev/hda of=/dev/hdb

for example will make an exact copy of the hda over hdb

the same with partitions

Code:

dd if=/dev/hda1 of=/dev/hdb1


but can bring you troubles if the partitions aren't of the same size

you can save to a file too

Code:

dd if=/dev/hda of=/mnt/disk/backup


another way would be to use find and cpio,something like

Code:

find ./  -path './proc' -prune -o -mount  -print | cpio -p --make-directories --preserve-modification-time destination-directory


this will copy all the content of you partition (assuming your possitionated in /) without copying /proc or mount partitions, to a directory

you can use -o param in cpio to make an image instead of copying files (-i to extract)

some guys use rsync too, wich will update your image instead of making a full copy every time
Back to top
View user's profile Send private message
Red-Drop
n00b
n00b


Joined: 10 Mar 2005
Posts: 37

PostPosted: Fri Jun 03, 2005 3:02 am    Post subject: Reply with quote

Thanks for the reply.

So esentilay of I do

Code:


dd if=/dev/hda of=/mnt/backup/systembackup3-5-05



and then restore with

Code:


dd if=/mnt/backup/systembackup3-5-05 of=/dev/hda



This will work as long as i buy the same brand and model of HDD. will it restore my partitions onto the blank drive on hda?

Must this be done in single user mode?

Assuming that my HDD's are in raid 1. Here is my raid tab

Code:


#/boot
        raiddev /dev/md0
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda1
        raid-disk       0
        device          /dev/hdd1
        raid-disk       1
#/
        raiddev /dev/md1
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda3
        raid-disk       0
        device          /dev/hdd3
        raid-disk       1

#/usr
        raiddev /dev/md2
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda5
        raid-disk       0
        device          /dev/hdd5
        raid-disk       1

#/var
        raiddev /dev/md3
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda6
        raid-disk       0
        device          /dev/hdd6
        raid-disk       1

#/tmp
        raiddev /dev/md4
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda7
        raid-disk       0
        device          /dev/hdd7
        raid-disk       1

#/home
        raiddev /dev/md5
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1

        device          /dev/hda8
        raid-disk       0
        device          /dev/hdd8
        raid-disk       1



Code:


dd if=/dev/hda of=/mnt/backup/systembackup-hda-3-5-05
dd if=/dev/hdd of=/mnt/backup/systembackup-hdd-3-5-05



and then restore with

Code:


dd if=/mnt/backup/systembackup-hda-3-5-05 of=/dev/hda
dd if=/mnt/backup/systembackup-hdd-3-5-05 of=/dev/hdd



Will the system boot as normal ie will it copy over the boot block and othere relevant information to the raid?
Back to top
View user's profile Send private message
Red-Drop
n00b
n00b


Joined: 10 Mar 2005
Posts: 37

PostPosted: Sat Jun 04, 2005 7:36 am    Post subject: Reply with quote

Is the above correct?
Back to top
View user's profile Send private message
Rad
Guru
Guru


Joined: 11 Feb 2004
Posts: 401
Location: Bern, Switzerland

PostPosted: Sat Jun 04, 2005 9:05 am    Post subject: Reply with quote

You have raid 1? No need to backup BOTH drives then; they're identical anyways...

And yes, you copy the MBR as well; so theoretically this could affect booting. If you alter the MBR after having made the backup, restoring the backup will install the old MBR (bootloader stuff and partition table) again.
I think that's what you want to happen, tho.

If not, you can still use the "skip" - Argument of dd to restore without the boot loader stuff / partition table / MBR or even just specific partitions by additionally using the "count" and "bs" arguments besides "skip". Also, you can loopback mount the image, so you can access the files directly and copy them. You can get the correct offset value for dd's "skip" argument or "losetup -o" (well, or mount's -o loop=/dev/loopX,offset=) by using "/sbin/fdisk -l -u" on the image, and then multiply the starting sector with the block size fdisk also displays...


Maybe I gave a bit too much advice now, cos it's pretty unlikely that you'll ever have to do anything besides restoring the entire disk as described below... 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum