Current page : Home      Backup_Restore

BACKUP AND RESTORE UBUNTU 

You can save your installed packagelist so you can easily reinstall all previously installed packages.

BACKUP

You need to create the file that will contain a list of all of the applications you have installed on your system (unfortunately this does not include packages you have built from source) open a terminal and type the following:

  • dpkg --get-selections > selections.txt


The file selections.txt should have been created and if all worked will be located in your home directory.  You need to keep your selections.txt and a file named sources.list in a safe place, preferably on a storage disk so if you have to reinstall your distro both files will be readily available.

I would suggest that you create a folder to store your backups in, somewhere in your home directory ie /home/[your_name]/backup so any backup data is easily found.


To create a directory follow the instructions below.  Please replace [your_name] with the correct path for your home folder, mine would be /home/karen/backup.

Open a terminal and type the following:

  • mkdir /home/[your_name]/backup


The backup folder will only be created once as when you do future backups the folder will already have been created, so if you already have a backup folder follow the next steps using the location of your backup folder.

You will now need to copy both files into your new backup folder, type the following:

  • cp /home/[your_name]/selections.txt /home/[your_name]/backup/selections.txt
  • cp /etc/apt/sources.list /home/[your_name]/backup/sources.list


That is your backup done, however, I would strongly recommend that you copy your backup folder onto a storage disk.

It's also a good idea to backup your /home directory with all the configurations for example the hidden files for .firefox, .kde and .mozilla as these hold all the settings you have set up previously like all your bookmarks in firefox. Just copy the folders back into the same location they originally came from.

RESTORE

To restore or install Ubuntu with the same packages after a new install you will need to copy your sources.list into the apt directory. But first you need to install Ubuntu and do the updates (ensure the updates are done before continuing), then backup your original sources.list before you do anything else.

To backup original sources.list open a terminal and type the following:

  • sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup


Then you need to save your previously saved backup sources.list into the folder /etc/apt replacing the existing copy, and the backup selections.txt, you will need to know the path of where the backup files are stored, I will assume that you have copied your backup folder from the disk into your home folder.

In the terminal type the following:

  • sudo cp /home/[your_name]/backup/sources.list /etc/apt/sources.list
  • sudo cp /home/[your_name]/backup/selections.txt /home/[your_name]/selections.txt


You will now need to update the package list, import the list of the packages you want to install and install them, to do that in a terminal type the following:

  • sudo apt-get update && sudo dpkg --set-selections < /home/[your_name]selections.txt && sudo apt-get dselect-upgrade


If you had a lot of packages installed this will take quite a while but it is definately worth the wait as it saves a lot more time than trying to remember what you had installed previously.

If you wanted to restore your original sources list in a terminal type the following:

  • sudo cp /etc/apt/sources.list_backup /etc/apt/sources.list 


If you encounter any problems please visit us in the irc channel by following the 'Live Chat' links.