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