Distroname and release: Debian Squeeze
Backup to a network share, using dd.With dd it is possible to create full backup of harddisks and partitions.
Here we will make a backup of an Windows Partition only, including the MBR, so we are able to boot from this when restoring.
Please note that I take for granted that Windows is installed with NTFS. It is possible with XP and older to install with FAT, but not quite likely. If you have installed with FAT, please take this to consideriration when reading the guide and "replace" NTFS with FAT.
Also FAT partitions only support up to 4G og filesize, this is important if you are exporting to a network share with FAT.
It is ofcourse possible to use a USB harddisk or an NFS share instead. The only thing that is needed is to change the mountpoints to match the settings.
And yes, it will also work if another OS needs to be backed up. I just
Booting a Linux OSFirst, get an LiveCD / USB and boot from it, so that we boot into this and not the OS we need to backup.
There several live CDs outthere, here are some of them.
The BackupMount a samba/Windows Network share:
When the Linux OS is now booted, we can continue. First we create mountpoints, and mount the network share.
You will of course need the have user credentials that have write permissions to the share.
#mkdir /mnt/backup #mount -t cifs -o username=user,password=passwd //servername/sharename /mnt/backupList harddisk and partition table.
Next thing is to locate the partition where NTFS is located. Look for NTFS.
In the below example we can now see that the NTFS partition is /dev/hda5.We will need this info later on.
#fdisk -l Disk /dev/sda: 200.0 GB, 200049647616 bytes 255 heads, 63 sectors/track, 24321 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xf706f706 Device Boot Start End Blocks Id System /dev/hda1 * 1 12 96358+ 83 Linux /dev/hda2 986 24321 187446420 f W95 Ext'd (LBA) /dev/hda3 13 275 2112547+ 82 Linux swap / Solaris /dev/hda4 276 985 5703075 83 Linux /dev/hda5 1900 24321 180104683+ 7 HPFS/NTFS /dev/hda6 986 1899 7341642 83 LinuxBackup the Windows / NTFS partition (and only this partition):
Note, we pipe the input and compress it with gzip.This is not required, but a good thing for slower network connections.
Sit back,wait and enjoy a cold coke or simliar, it might take a while.
#dd if=/dev/hda5 | gzip -c | dd of=/mnt/backup/backupfilename.img.gzBackup MBR Only (Needed if partition only and not full harddisk):
Use the harddisk device and not partition for MBR backup and restore. In example /dev/hda. MBR is located on the harddisk itself and not a partition. This is quite important, or else the backup of the MBR will be useless.
The example below copies only the first 512 bytes where the MBR is located.
#dd if=dev/hda of=/mnt/backup/mbrfilename.img count=1 bs=512
The RestoreRestore Partition (Asumes that the network share is already mounted):
Also please note that we use gzip to decompress the image, because we compressed it earlier.
#dd if=/mnt/backup/backupfilename.img.gz | gzip -dc | dd of=/dev/hda5Restore MBR (Must be harddrive device not partition):
#dd if=/mnt/backup/mbrfilename.img of=/dev/hdaUsing a SSH connection
It is also possible to do direct to another host using ssh without need need of mounting. Just be sure that the host have enough storage available if it is backup of a large partition or harddisk.
dd if=/dev/hda5 bs=1k |gzip -c| ssh user@hostname dd of=backup.gz