I've found the cleanest way to upgrade Ubuntu is to do a fresh install. Here is a list of steps that I take to upgrade.
- Backup Your Installed Applications
Unfortunately, Ubuntu does not provide a tool to backup/restore your currently installed applications. However, there is a way! Using dpkg you can dump a list of your installed packages into a text file, which you can used later to reinstall them. I found this method in the Ubuntu forums, but will repost it here from convenience.
To dump a list of your installed packages into a text file run this.
dpkg --get-selections > installed-software
Make sure to store this file in your user directory for the next step.
- Backup Server Configuration (optional)
If you don't use Apache or MySQL you can skip steps 3, 4, 8, and 9.
Backup your /etc/apache2 folder.
sudo tar cfzv apache_backup.tar.gz etc/apache2/ sudo mv apache_backup.tar.gz /home/username
- Backup MySQL Databases (optional)
Dump your databases to a text file.
mysqldump --all-databases -uroot -p > mysql.backup.sql sudo mv mysql.backup.sql /home/username
- Backup your user directory
It's best practice to keep all of your files in your user directory (/home/<username>/), so hopefully you won't need to to worry about much outside of this. I've used both SBackup and Rsync for backup. Both are available via Synaptic or apt-get. I prefer Rsync and highly recommend install the gui package Grsync, which is also available via Synaptic or apt-get. I backup to an external hard drive. If you have large files, i.e. larger than 4GB, make sure your external hard drive uses a file system that supports large file transfers. I had to reformat my external drive because it was formatted fat32, which only supports 4GB file transfers. You can install grsync like this.
sudo apt-get install grsync
- Install Ubuntu!
Download the latest and greatest Ubuntu image from www.ubuntu.com. Burn the images to CD or to a thumbdrive and follow the installation instructions.
- Merge the backup of your user directory into your new user directory
You don't want to copy everything from your previous user directory to the new user directory just yet. Ubuntu applications store configuration settings in your user directory, usually in directories that start with ".". You can copy everything and risk it, but I prefer to just copy my personal files first and restore application configuration directories as needed. You may not need the old ones at all!
- Reinstall your application packages
First, select the packages to install from the text file we created in step 1.
dpkg --set-selections < installed-software
Now, we need to install them.
This may take some time.
- Restore your apache configuration (optional)
Copy your apache backup to your new user folder and extract it. Then overwrite your existing apache config directory with your backup.
sudo cp -f -r apache2 /etc/apache2
Restore MySQL Databases (optional)
Restore the databases from the dump file that we created in
mysql --verbose --user=XXXXXXXX --password=XXXXXXXX DB_NAME < /PATH/TO/DUMPFILE.SQL