Thursday, November 24, 2011

Linux Dump Command to move data to another hard drive (dump, restore, backup) !

dump Linux Commands

Explanation

dump COMMAND:
     dump command makes backup of filesystem or file and directories.

SYNTAX:
  The Syntax is
     dump [options] [dump-file] [File-system or file or directories].

OPTIONS:
    
-[level]     The dump level any integer
-f     Make the backup in a specified file
-u     Updates /etc/dumpdats file for the backup made
-v     Displays Verbose Information
-e     Exclude inode while making backup

EXAMPLE:
    
    To make a backup for a directory or file :

    dump -0uf databackup /home/user1/data

    This command creates a dump-file called databackup which is the backup of /home/user1/data directory.
    In above command:
    -0    -Is the dump-level [0 specifies full-backup]
    databackup    -Is a dump-file [or backup-file]
    /home/user1/data    -Is a directory for which a backup is created
    To make a backup for a directory or file which is already backedup with dump level 0:

    dump -1uf databackup /home/user1/data

    This command backups all the new files added to /home/user1/data directory after level-0 dump is made.
    -1    -Is the dump-level [1 specifies incremental backup]
    databackup    -Is a dump-file [or backup-file]
    /home/user1/data    -Is a directory for which a backup is created

Move data  to another hard drive (dump, restore, backup)
        There are several methods to move running Linux to another hard drive at the same server. But I used Unix dump/restore utility to perform this…
First of all it’s necessary to partition new hard drive in the same way as it’s done with old drive (Linux is running at). I usually use ‘fdisk’ utility. Let’s assume that old drive is /dev/hda and new one is /dev/hdb. To view hda’s partition table please run ‘fdisk -l /dev/hda’ which should show something like this:
Disk /dev/hda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 15 120456 83 Linux
/dev/hda2 16 276 2096482+ 82 Linux swap
/dev/hda3 277 7297 56396182+ 83 Linux
After this run ‘fdisk /dev/hdb’ and make the same partitions at it. Interactive mode of fdisk utility is well documented and is very intuitive, so I don’t think it would be difficult to perform partitioning.
After this is done, we should make new filesystems at partitions we’ve created:
mkfs -t ext3 /dev/hdb1
mkfs -t ext3 /dev/hdb3
mkswap /dev/hdb2
When it’s done it’s NECESSARY to mark newly created filesystems as it’s done with old ones. To check filesystem volume name run command ‘tune2fs -l /dev/hda1 | grep volume’ and etc. You’ll see something like this:
Filesystem volume name: /boot
It means that we should mark new hdb1 with label /boot. It can be done by command:
tune2fs -L “/boot” /dev/hdb1
The same should be performed for all partitions except swap one. In my case I should label hdb3 by command:
tune2fs -L “/” /dev/hdb3
At this point new hard drive preparation is finished and we can proceed with moving Linux to it. Mount new filesystem and change directory to it:
mount /dev/hdb1 /mnt/hdb1
cd /mnt/hdb1
When it’s done we can perform moving by command:
dump -0uan -f – /boot | restore -r -f -
And the same with / partition:
mount /dev/hdb3 /mnt/hdb3
cd /mnt/hdb3
dump -0uan -f – / | restore -r -f -
When dump/restore procedures are done we should install boot loader to new HDD. Run ‘grub’ utility and execute in it’s console:
root (hd1, 0)
setup (hd1)
quit
In case everything is done carefully and right (I’ve tested this method by myself) you can boot from new hard drive and have ‘old’ Linux running at new hard drive running.

Read more: http://www. linuxscrew. com/2007/08/13/move-linux-to-another-hard-drive-dump-restore-backup/#ixzz1ec9eDb3z