Today Kyle writes:
I have been using Ubuntu for a couple years now, and I am pretty comfortable with day-to-day computing on the platform. However when it comes time to do a version upgrade with a fresh install (I don’t trust the upgrader, it doesn’t work properly in my experience) I’m often frustrated by having to install a whole bunch of software, grab a bunch of PPAs, and deal with a bunch of broken settings. I’ve been using DejaVu to backup and transfer my home folder, but I’m wondering what is the “right” way to do a version upgrade?
Well Kyle, it sounds like you’re half way there. You already understand the value of backing up your home directory. And this is a good thing, as it’s easier to piece together lost software than it is lost personal documents, pictures, etc. All of this said, I am going to show you a bullet proof method for backing up your software. This method works for both migrating software, as well as simply doing a fresh installation on the same system. Be sure to follow the steps carefully.
Backup your home directory
Using Déjà Dup to back up your home directory first needs to be your first order of business. Why? Because your home directory has your software settings, in addition to your pictures, documents, videos, and various other Ubuntu-specific account information. Restoring it, will make your life easier as it contains irreplaceable data. This article does not cover backing up this data — it only creates a special backup of your software titles, not the data within them. Moving on.
Backing up your Ubuntu Software
Backing up your software is much easier that most tutorials out there might have you believe. Most of them, rely on the dpkg –set-selections method which in my opinion, is a nightmare waiting to happen. Sure, it should work without any hassles. Unfortunately though, this isn’t always the case. I’ve found that more often than not, it creates conflicts. Worse than that, you really don’t get to sort out what you’re going to backup and what you’d rather just avoid. It’s messy and to be avoided in my opinion. Using Synaptic however, offers a simple, GUI solution that anyone of any skill level can follow.
There are line breakages on purpose, due to formatting — so copy carefully.
1) Backup your PPAs and your PPA keys. To do this, simply run the following commands in a terminal window.
sudo cp -r /etc/apt/sources.list.d /Like-a-FlashDrive
The above command, is what will pull your PPAs from your apt directory, make a copy of them and drop them into the directory of your choosing. I recommend something like Dropbox or a USB flash drive. Anything that isn’t attached only to your hard drive, is a safe bet. No need to add sources.list.d to the destination, since it’s merely a copy of the existing PPA area.
2) Backup your PPA keys! This is what will allow you to connect to the PPA servers and add/remove software from them. Without these keys, you’re going to be stuck rebuilding the keys from a terminal and if you have a lot of them, this is time-consuming.
sudo apt-key exportall > /Like-a-FlashDrive/repositories.key
This command will make sure that all the relevant gpg keys for your PPA repositories, will be backed up as well. From there, the next step in the backup process is simply to run Synaptic and do the following from within the GUI.
File>Save Markings As>Click “Save full state, not only changes”
Checkbox>choose Destination-like-a-FlashDrive>Click Save
Be sure to name the backup something you recognize, like “SoftwareBackup.”
Restoring your Ubuntu software
On your new computer or perhaps the same PC, with a clean installation of Ubuntu, follow these instructions to restore your Ubuntu software settings. Realize though, that these settings are pretty deep. So it pays to watch the video below to make sure you don’t miss anything. Okay, to restore your software. Once you’ve moved your “sources.list.d” folder, “repositories.key” file and “SoftwareBackup” file to your new home directory, you’re ready to begin the software restoration. If this is being done on a backed up home directory, simply restore your home directory and continue below instead.
1) Restore your PPA repos. If you’ve got everything in your home directory as instructed above, go ahead and do the following.
sudo cp -r ~/sources.list.d /etc/apt/
This copies your backed up sources.list.d folder from home to your apt folder.
2) Next, we need to authenticate your PPAs. They need their keys back!
sudo apt-key add /home/matt/repositories.key
Awesome, onto the last step!
3) Restore the software titles themselves. Remember, your software settings are stored in your home directory. So this restoration only restores the installation of the software, not their settings. Restoring a backup of your home directory will get the settings back into place. Open up Synaptic on the new install or new PC, and follow this last step.
File>Read Markings>Browse to home dirctory>Select SoftwareBackup file>Open>Review software selections>click Apply
The video below will show you how easy the restore process is.