Login or e-mail Password   

The noobs guide to dump and restore.

How to save your data using simple tools.
Views: 1.612 Created 07/13/2008

Hey again.

Basicly , what i had to do was move a filesystem from one hard drive to another, due to the first one starting to have problems ( as reported by S.M.A.R.T. and whatnot else ). There are complicated solutions to this, but i tried to stay as simple as possible.

apt-get install dump

Nice and easy. Then i got this nifty shell script :

#!/bin/sh
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
for i in `echo hda1 hda5 hda7 hda8 hda9 `; do
dump -0 -u -a -f - /dev/$i|gzip -c > /mnt/backups/backup-$i-`date +%F`-level0.gz
done

Using this script will create a few files named like backup-hda1-2007-11-29-level0.gz. You can setup a cronjob with that for let's say every morning in 6 AM, so you will always have a reasonably decent backup of your filesystem.

Now lets head over to the restore. Assuming you have the exact same size hard disk you will move your filesystem to, you will need to create the partitions on it. Plug your second hdd and boot the system with the current one.

fdisk -l

This will give you something like this :

Device Boot Start End Blocks Id System
/dev/hda1 * 1 33 265041 83 Linux
/dev/hda2 34 9729 77883120 5 Extended
/dev/hda5 34 642 4891761 83 Linux
/dev/hda6 643 970 2634628+ 83 Linux swap / Solaris
/dev/hda7 971 1031 489951 83 Linux
/dev/hda8 1032 3463 19535008+ 83 Linux
/dev/hda9 3464 9729 50331613+ 83 Linux

At the end of this there should be info about your second hdd. We will assume that it is /dev/hdb ( primary slave ). You need to create the partitions again.

fdisk /dev/hdb

Typing m and pressing enter will show you a short help. Basicly it goes down to :

  1. Create a new primary partition ( 1 ) -> n, p, 1
  2. Create an extended partition
  3. Create hdb5-8 partitions ( logical ).
  4. Create a swap partition.

After you have this done use mkfs.ext3 on each of the new partitions like :

mkfs.ext3 /dev/hdb1

Now create a few directories like this :

mkdir -p /mnt/hdb1
mkdir -p /mnt/hdb2
mkdir -p /mnt/hdb5
mkdir -p /mnt/hdb6
mkdir -p /mnt/hdb7
mkdir -p /mnt/hdb8
mkdir -p /mnt/hdb9

Here comes the fun part. Go to /mnt/backups and issue :

gunzip *.gz

Should take a while , depending on how big your filesystem is. After this is done, start mounting the new partitions into their corresponding directories and restoring backups, one at a time, starting from the highest number ( i.e. 9 ).

mount /dev/hdb9 /mnt/hdb9

Then :

restore rf /mnt/backups/backup-hda9-2007-11-29-level0

Repeat this for all of the partitions ( note that hdb6 in my case was swap, so it wont be dumped, nor restored ).

After you're done with it, you have to make sure that /dev/hdb1 is marked bootable. Then run grub and issue :

install /boot/grub/stage1 (hd1) /boot/grub/stage2

setup (hd1)

reboot

After the box reboots, stop it , remove your primary hdd and replace it with the one you've just created ( don't forget to set it as primary master ).

That should be it. I might have missed a thing or two, so any question feel free to ask them :)

I realize that this is far from perfect or *advanced*, but it works :)

Similar articles


15
comments: 18 | views: 20875
11
comments: 5 | views: 15499
10
comments: 4 | views: 5034
10
comments: 7 | views: 10028
8
comments: 4 | views: 3758
 
Author
Article

Related topics






No messages


Add your opinion
You must be logged in to write a comment. If you're not a registered member, please register. It takes only few seconds, and you get an access to additional functions .
 


About EIOBA
Articles
Explore
Publish
Community
Statistics
Users online: 122
Registered: 99.752
Comments: 3.259
Articles: 7.810
© 2005-2017 EIOBA group.