View previous topic :: View next topic |
Author |
Message |
Red-Drop n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Mario/Mario_-_Mario.gif)
Joined: 10 Mar 2005 Posts: 37
|
Posted: Thu Jun 02, 2005 3:22 pm Post subject: Creating a disk image of my server |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Cadorna Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 30 Dec 2004 Posts: 215 Location: Argentina
|
Posted: Thu Jun 02, 2005 8:37 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Red-Drop n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Mario/Mario_-_Mario.gif)
Joined: 10 Mar 2005 Posts: 37
|
Posted: Fri Jun 03, 2005 3:02 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Red-Drop n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Mario/Mario_-_Mario.gif)
Joined: 10 Mar 2005 Posts: 37
|
Posted: Sat Jun 04, 2005 7:36 am Post subject: |
|
|
Is the above correct? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Rad Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 11 Feb 2004 Posts: 401 Location: Bern, Switzerland
|
Posted: Sat Jun 04, 2005 9:05 am Post subject: |
|
|
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... ![Cool 8)](images/smiles/icon_cool.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|