Backup of Debian/Ubuntu Linux Distros

fail Mar 29, 2009

Free and Open Source Software has a really good feature. It is always there! So today I decided to destroy my Linux Virtual Machine. I needed more room, and didn’t feel like running it through VMware converter. Since deploying a new VM takes about ten minutes, I just decided to start from scratch. This is also a good time to practice worse case scenarios.

Click “Read more” to view the whole article.

[Update #1 – I needed to do a “apt-get install dselect” to install dselect on my gOS 3.1 distro.]

First we will need to know what is installed on the system. Apt-get is the package manager for Debian/Ubuntu. We will use this to get all our installed programs and re-install them automagically.

First the Backup of the list of installed software

This lists all your installed programs:
$ dpkg –get-selections

This sends it to a text file in your current location:
$ dpkg –get-selections > installed-software.log

Save “installed-software.log” to somewhere safe like an external drive, or your Mac ;)

Next, we will need to backup our files. I personally keep everything in my home directory. so we will be backing up /home/user or in my case /home/jeremy

To do this we will be using Tar to archive since it is native to most Linux distros and easy to use. We will need to be logged out as our regular user and logged in as root (the super admin).

To compress the directory use this command:

tar czvfp home-backup.tgz /home/jeremy

This will create an archive called “home-backup.tgz” in your current directory. Back this up to CD/DVD/HardDrive/Mac or something that will not break.

Now to Restore

First we need to install Ubuntu/Debian, and run the updates (covered elsewhere in the internet or another article if I make it).

Restore previously installed software from backup list

This command tells dpkg to select the previously installed programs:

dpkg –set-selections

This command tells the machine to “Just doit!” in a Bronx accent.

apt-get install dselect


Select ‘i’ for install the software then just hit enter.

Once that is done…after many, many, many minutes. you will have a system with the same programs as you previously had except for programs built from source, but that is another topic for another day.

Next we restore our files.

Copy over the “home-backup.tgz” from you secret secure bunker, and untar it into the unsuspecting home directory on the new system.

tar xzvf home-backup.tgz /home

Reboot or Login and you will be good to go.


PS – If you have any comments or questions, hit me up on Twitter or Facebook.


Utopia Machine

Enthusiastic highly imaginative senior technologist with creative approaches to solving problems