2

I just bought a dedicated server with debian 6. I will install the classic LAMP.

Is there a way to make an image of the hard disk so in case of any problems I can restore this image?

Thanks

6 Answers 6

4

I did use tar to copy live linux system to another computer and there were only minor problems such as stale lock files. You can use tar together with ssh to copy whole filesystem:

ssh user@host tar c /etc /usr /var ... > image.tar

Add compression and other tar switches as appropriate. Make sure that you aren't copying virtual filesystems such as /dev or /proc , there should be only empty directories. On the target system boot off live CD, create partitions and filesystems and extract image.tar from USB or network.

However, after the target system is up and running, it is best to copy most vital data in a safe way (i.e. dump/restore databases).

1
  • 3
    That will not make an image of the disk, that will take a copy of files on the file system.
    – Jason Tan
    Feb 9, 2011 at 0:20
3

To make an exact image of the disk try something like

dd if=/dev/sda |ssh user@remotehost "cat > image.bin"

You'd run that on the host whose disk you want to backup and replace /dev/sda with the disk device you want to backup.

1
  • 1
    If /dev/sda (in this example) is mounted, your image will likely be inconsistent. Make sure to umount the device and/or run this command from a rescue boot. Feb 9, 2011 at 3:20
1

I once used partimage to back up live running machine 500 km away (bad sectors on a disk, no previous backup, no technician on site), scp it to my home machine, install it to a newly bought disk, and mail it to a location which was installed without hicckups and with minimum downtime. This tool copies the boot manager, true "bare metal" recovery. Others recommended dd which copies every byte of disk (imagine 1TB disk with 2 GB installed OS!!!), and tar which does not copy the boot sector.

1
  • wow that's a lot of stuff
    – dynamic
    Feb 9, 2011 at 0:06
0

Well, the obvious problem here is what to do with writes going on while you are taking an image, so the short answer is no, you can't make 1:1 HDD image using just ordinary command line tools. But this is probably not what you want anyway since you can't remotely restore a full HDD image too. So, the best way to proceed from my point of view is to perform backups on a higher level: backup files (or even full / structure with exception of /proc and /sys), not HDD image.

2
  • Hmm, I would avoid to do it manually. I thought there was a command that would backup the entry HDD with a reboot maybe
    – dynamic
    Feb 8, 2011 at 23:04
  • If you can boot to some kind of external rescue Linux distro, probably from CD or USB stick, you can backup the full HDD, otherwise you can't.
    – Alex
    Feb 8, 2011 at 23:08
0

If you boot from another disk (live cd?), then you can use the dd command to achieve this.

Edit: Ooops, missed the subtle mention of SSH in the subject. Whilst you could use dd on the live filesystem, I suspect if you restored the image, that it probably wouldn't work.

1
  • I don't have physical access. SSH only
    – dynamic
    Feb 8, 2011 at 23:05
0

If you bought a vps some providers provide a sort of rescue system remotely accessible which has a remote console for accessing your virtual machine without starting the operating system. If this is your case you can boot the rescue system and make a full image of your hard disk. Otherwise you simply can't using ssh.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .