Disk Backup should be one of the major event any Computer user or System Administrator should do periodically. Critical data loss will have a financial or Security impact on companies of all sizes. There has been certain cases, where few System Administrator have seen loosing their job due to data loss. So, It's better to have backup than to have nothing. We will be using `dd` unix command. Follow tutorial Carefully.
So, today we are going to see, how we can backup our data using ` dd ` unix command.
1. ` How to Backup Entire Disk ? `
Below command is not Reversible, so be careful and check thoroughly before you press enter.
Code:
root@linux# dd if=/dev/sda of=/dev/sdb
- “if” represents inputfile, and “of” represents output file. Above command will copy /dev/sda` to available /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 any read errors.
- Input file and output file should be mentioned very carefully, if you mention your source file i.e, /dev/sda in output file "of", than you will loose all your data, and all you will be left with will be using "testDisk" utility.
If you want to copy the file in synchronised I/O, add `sync` parameters.
Code:
root@linux# dd if=/dev/sda of=/dev/sdb conv=noerror,sync
2. ` Create an Image of a Hard Disk `
if you ever wanted to know, how to create disk image , than this is for you.
Code:
root@linux# dd if=/dev/sda of=~/hdadisk.img
There are many advantages to backing up your data to a disk image.
- It's ease of use.
- This method is typically faster than other types of backups, enabling you to quickly restore data.
3. ` 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. Make sure, you have saved or backedup all your old data before restoring,
Code:
root@linux# dd if=hdadisk.img of=/dev/hdb
The image file hdadisk.img file, is the image of a /dev/hda, so the above command will restore the image of /dev/hda to /dev/hdb.
4. ` 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.
Code:
root@linux# dd if=/dev/hda1 of=~/partition1.img
5. ` CDROM Backup `
dd command allows you to create an iso file from a source file. So we can insert the CD and enter dd command to create an iso file of a CD content.
Code:
root@linux# dd if=/dev/cdrom of=tgsservice.iso bs=2048
Thanks, If you have any question ask them below.