create an image of currently linux installed with ssh?

11,928

Solution 1

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

Solution 2

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.

Solution 3

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:
11,928

Related videos on Youtube

dynamic
Author by

dynamic

Updated on September 17, 2022

Comments

  • dynamic
    dynamic over 1 year

    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

  • dynamic
    dynamic over 13 years
    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
    dynamic over 13 years
    I don't have physical access. SSH only
  • Alex
    Alex over 13 years
    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.
  • dynamic
    dynamic over 13 years
    wow that's a lot of stuff
  • Secoe
    Secoe over 13 years
    That will not make an image of the disk, that will take a copy of files on the file system.