Pin Me

Creating and Restoring Disk Backups in Linux

written by: Pranav Thadeshwar•edited by: Lamar Stonecypher•updated: 5/27/2011

With huge hard-drives, growing sizes of file-formats and personal stuff, it's very easy to start filling up your disks. But have you ever taken the trouble of backing up that important data? Losing hundreds of hours of work or personal things like photos or videos can be traumatic. Backup that data!

  • slide 1 of 7

    Introduction

    It is a fact that everyone will experience a disk crash one day. The smart ones have taken precautions and backed up their data. The not-so-smart ones probably wish they had. With storage getting cheaper and disks getting bigger, it's foolish to leave your data in danger. Disks can be bought again, but data is lost forever. And the most unfortunate thing is that this happens when there are so many backup solutions to choose from, with literally something for everyone. Read on and backup your data today. A disk-crash could happen tomorrow!

    If you've read this far, chances are that you're interested in saving your backside should a disk crash happen in the future. Be aware that you will need to devote a small part of your time towards maintaining your backups and making sure it's all working fine. But it'll pay off heavily one day, when you will lose an hour restoring your backup, rather than years of work and memories. Like I said above, there are loads of backup solutions to choose from. You can try Live CDs which will boot into a clean environment, mount your disks and backup everything within a few minutes to a couple of hours. Or you can install applications using your package manager which will backup everything while you work at the same time.

  • slide 2 of 7

    Partimage

    Partimage: Partimage is a Linux application which backs up complete partitions to image files. These files can then be compressed and archived for future use. Since the backup is saved as one file, you can easily move it around on a portable drive or upload it online or across your network for backing up. Restoring this image file later is a short and fast process, not taking more than 10-15 minutes generally. Partimage can be installed as a package through your distro's package manager or run through SystemRescueCD, a Live CD with loads of other recovery-related tools.

    Package Manager: Most modern distros will have Partimage in their repositories and a few clicks will install it on your system. Once installed, run it from the command line by typing

    sudo partimage

    Partimage screenshot 

  • slide 3 of 7

    SystemRescueCD: It is a complete solution to carry out all sorts of backup/recovery and diagnostics on your system. Weighing in at a convenient ~250MB, it contains tools for partitioning your drives, backing up and restoring/recovering your data, and various other tools which make it convenient for you to do the above. The tool we're interested in is Partimage. Navigate to the site and download the relevant image for your computer's architecture (you're most probably using an x86 arch.) Once downloaded, burn the ISO image (as a bootable CD) using your favorite CD-burning application, and change your BIOS boot order to boot from CD. Once there, just press Enter to boot the CD and then run Partimage.

    Even though Partimage is a command-line application, it is incredibly easy to use and self-explanatory, with keyboard shortcuts and instructions mentioned everywhere. Here are a few screenshots showing the same.

    Trinity Rescue Kit: Or TRK for short is another all-in-one recovery and diagnostic solution, calling itself the CPR for your computer. It contains a few more features than SystemRescueCD. Same drill as before, download the ISO image, burn it and boot it. Here are some screenshots of it.

  • slide 4 of 7

    BackupPC

    If you have a network in place and more data to move around, you'll surely appreciate BackupPC. Geared towards an enterprise crowd, it bundles features not found in Partimage. Since it's an application that runs on your system, you have the convenience of scheduling your backups without having to reboot and run a Live CD. It will allow you to backup your specified files/folders and copy them across your local network and archive them.

    BackupPCServerStatus 

    Further backups of the same will only store the changes rather than the complete file. Because of this, once you have a complete backup of your drive, everyday-use should not produce more than a few megabytes of incremental backups. It will also allow you to restore different versions of the same file, depending on how far back your backups go. And you manage the application using a web-based frontend through your browser, so you don't have to remember commands or go through man pages.

    If you have multiple computers, BackupPC will allow you to pool backups, combining all the common files between them. These will then be stored on a common server in your network. Accessing these backups is made easier by allowing directory browsing through the backups and selecting which files you want to restore. They can then be restored directly to the desired computer or downloaded in zip/tar form through your browser.

    To install it, please check your distro's package manager. If your distro's package manager does not have it, download it from its official site and follow the README file. Click here to check out a few screenshots.

  • slide 5 of 7

    TimeVault is another snapshot-style backup program inspired by Apple's Time Machine in Mac OSX. After installing it using your package manager, you create a base backup which will have a complete backup of your selection. Any further backups after that will be incremental and store just the differences rather than complete file. This is possible using rsync functionality found in Linux. Since these backups are small, you will not be wasting any space storing duplicate files. When restoring files, you just have to select which revision you'd like to restore and press the Revert button. It will automatically re-create the file as saved on that particular day and restore it.

  • slide 6 of 7

    TimeVault

    TimeVault window 

    Since TimeVault is relatively new, you will not find it in your distro's package manager most probably. No problem though, navigate to its site and download the package relevant to your distro (.deb if you are on Ubuntu or Debian, .tar.gz for any other distro). Also, I would wait for a stable version before using it for important stuff. After all, backing up your important data using an unstable application is an exercise in foolishness.

  • slide 7 of 7

    Final words

    These applications are just the proverbial tip-of-the-iceberg. With the freedom you get in Linux, not only can you expect to have new functionality everyday, but new applications too. And with base functionality and applications like dd, rsync, ssh and tar, you can roll your own custom backup solutions using scripting in a matter of a few hours. The sky's the limit... literally.

    Once you've made backups, check them to see if they're working. The last thing you want is an invalid/corrupted backup when you're hoping to recover your data. Make sure to read the documentation of whichever application you decide to use, and observe caution when restoring from backups.