2015-10-16

[SOLVED]Backup Linux Using dd Command (Including Disk to Disk)

#10:47 17/09/2015
#http://www.thegeekstuff.com/2010/10/dd-command-examples/


#Backup Entire Harddisk
#######################
# dd if=/dev/sda of=/dev/sdb
    “if” represents inputfile, and “of” represents output file. So the exact copy of /dev/sda will be available in /dev/sdb.
    If there are any errors, the above command will fail. If you give the parameter “conv=noerror” then it will continue to copy if there are read errors.
    Input file and output file should be mentioned very carefully, if you mention source device in the target and vice versa, you might loss all your data.

In the copy of hard drive to hard drive using dd command given below, sync option allows you to copy everything using synchronized I/O.
# dd if=/dev/sda of=/dev/sdb conv=noerror,sync


#Create an Image of a Hard Disk
###############################
Instead of taking a backup of the hard disk, you can create an image file of the hard disk and save it in other storage devices.There are many advantages to backing up your data to a disk image, one being the ease of use. This method is typically faster than other types of backups, enabling you to quickly restore data following an unexpected catastrophe.
# dd if=/dev/hda of=~/hdadisk.img
dd if=/dev/mapper/vg_srv162-lv2_os of=/opt/bk-data/harddisk-20150917-1.img

The above creates the image of a harddisk /dev/hda. Refer our earlier article How to view initrd.image for more details.
(http://www.thegeekstuff.com/2009/07/how-to-view-modify-and-recreate-initrd-img/)



#Restore using Hard Disk Image
##############################
To restore a hard disk with the image file of an another hard disk, use the following dd command example.
# dd if=hdadisk.img of=/dev/hdb



#Backup a Partition
###################
You can use the device name of a partition in the input file, and in the output either you can specify your target path or image file as shown in the dd command example below.
# dd if=/dev/hda1 of=~/partition1.img

No comments:

Post a Comment