DD Backups over SSH

To perform backups of a local workstation’s hard disk over a network, perform the following procedures (adjusted to your particular situation of course):

  1. Download and boot from a live Linux distro
  2. Become “root” within a shell
  3. Run “fdisk -l” (“mac-fdisk -l” I know works on SystemRescueCD 0.2.0 (PPC) for PPC/Macs (what about Intel Macs?)) and note the internal hard disk partition to backup (ex: ‘/dev/hda’)

The rest assumes that (in short, you will probably have to substitute some numbers or devices and you have ssh access somewhere):

  1. You have network access
  2. You have access to an SSH server
  3. Your network is configured with private addresses and you are not assigning one that conflicts with another local IP address
  4. Your netmask is the same as the one supplied in the following commands

Give an IP address to the workstation you have just booted the live Linux disc on, set the netmask, and bring the network interface up:

ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up

Set the default gateway (if you need to reach outside of the LAN that is… normally this is your router’s IP address):

route add default gw 192.168.1.1

Set a DNS server (if you are in the habit of not strictly using IP addresses):

echo "nameserver 192.168.1.1" > /etc/resolv.conf

Execute the backup command:

dd if=/dev/hda | ssh username@backupserver.fqdn
"dd of=/directory_of_backups_on_ssh_server/backupfile.iso"

Obviously, most of the previous is getting the network up… try running “dhclient” if the live Linux disc has it installed, and your network has DHCP setup. 😉

UPDATE (2010-02-09): I just thought I would mention, that Clonezilla Live is a fantastic piece of software that makes this all a little more automated. Their site says, “For [supported] file systems, only used blocks in partition are saved and restored. For unsupported file system, sector-to-sector copy is done by dd in Clonezilla.” Essentially, this translates into much smaller image sizes for the majority of files systems that people work with. See a basic how-to at http://www.howtoforge.com/back-up-restore-hard-drives-and-partitions-with-clonezilla-live.

4 Comments

  1. What is the problem with making this with the system booted up normally from /dev/hda ? Is it really necesary to start with a live cd?

  2. This post is about imaging /dev/hda. If you are booted from /dev/hda, than I don’t think that it would be a good idea to try and image it (nor am I sure it is even possible… haven’t tried)… because you would have partitions mounted, that you are trying to image.

    Files would be changing, just by being booted off of the drive. Though you could be booted off of /dev/hda and image /dev/sda, or some other device.

  3. The drive that you are imaging has to be unmounted for the process to work so if you are going to image your primary boot partition you should boot from a live CD. Once you get the commands down dd + SSH is better than Norton Ghost and a lot cheaper.

  4. Thanks for the good and short tutorial.

    Found it helpfull.

    I’d like to mention, that if you are looking for

    a filesystem backup util in Linux, you maybe want try LVM!

    With LVM snapshots you can minimize the downtime of a

    running system when taking the backup.

    Further you can then copy, tar, cpio or rsync the LVM snapshot.

Comments are closed.