Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 2 down vote accepted

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).

share|improve this answer
That will not make an image of the disk, that will take a copy of files on the file system. – Jason Tan Feb 9 '11 at 0:20

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.

share|improve this answer
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. – toppledwagon Feb 9 '11 at 3:20

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.

share|improve this answer
wow that's a lot of stuff – dynamic Feb 9 '11 at 0:06

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.

share|improve this answer
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 '11 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 '11 at 23:08

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.

share|improve this answer
I don't have physical access. SSH only – dynamic Feb 8 '11 at 23:05

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.