HowTo Ghost Hard Drive to an FTP Server

If you aren’t familiar with the dd command, I encourage you to take a look at my post on dd located here.

Why I care

Sometimes it’s helpful to take a snapshot of your system or any other drive. If you’ve spent weeks setting up a new machine and installing all of your favorite programs, you might want to make a copy before it gets overwhelmed with spyware, malware, and bloatware. If the machine ever has problems, you can use the image to restore it back to what it looked like today…kind of like a moving recovery partition.

Why not use the Recovery Partition

Recovery disc and partitions are practically useless in the real world. A computer is a highly customized tool that continues to evolve from the moment it is first used. Over time, programs are added, settings customized, and files saved which become fundamental to the way that the computer is used. There are times that problems with Windows could be easily fixed by re-installing the operating system, however the rescue cd, or partition, does not give this option. Using these “rescue” options results in all data being deleted from the drive, all updates being removed, and all “trial software” being reloaded. Although helpful in the case of a catastrophe, the solution is almost worse than the cure.

Why use FTP

It’s not always sufficient to use a local disk. Here are some reasons you might want to backup to a local FTP server:

  • Backup a laptop harddrive using a Live CD
  • Store a backup on a different computer, in case of drive failure or catastrophe
  • You don’t have enough space on the local computer and want to push the image out to a local FTP server

The Process

  • Connect to the FTP server
  • Make an exact copy of the hard drive (or other block device)
  • Compress it
  • Send it to the FTP server

Some things to keep in mind, it is important to use a live CD or Pen Drive when doing something like this so that you are not booting or running anything off the drive you intend on copying. You don’t want to have any files open, especially system files or else you may save your hard drive in a state of confusion which will cause you trouble when you restore it.

Connect to the FTP server Open a terminal and type:

ftp
> open 192.168.0.100

where 192.168.0.100 is the address of your FTP server.

Next: Send the copy of the harddrive to the fTP server. If you are unsure of where your drive is assigned, use the fdisk command.

> put "|dd if=/dev/sda bs=32k | gzip" myimage.gz

This command will take a long time to run. What does it do? Let’s take a look. The put command through FTP uploads a file from the local computer to the FTP server. Instead of giving a file name as you normally would, you are sending it a stream of bytes which are generated from the dd program, which is a useful program for making a bit by bit copy from one drive to another. By using the pipe (‘|’) you are telling FTP to send the result of the dd program in to the line where it is expecting a file to be. The “if” parameter specifies the input file (in this case your hard drive). The “bs” parameter specifies the basic block size that should be used when copying. WE then use the pipe (‘|’) again to send the output of dd through gzip, to compress the image. Finally, we specify the filename that we want the image to have on the server.

How to Restore from the backup Reboot the machine in Linux, connect to the FTP server and do:

> get netbook.gz "| gunzip | dd of=/dev/sda"

Leave a Reply

Your email address will not be published. Required fields are marked *