System Backup: A manual approach

  7 years ago

A manual approach is going to be adopted to backup system without any backup softwares.

Why would anyone need a backup:

1. If you have a dual boot pc with windows and linux and the windows portion is broken somehow and only an automated system of installing windows is available at hand which will erase the whole hard disk, like sending it to a service center, or in a office which doesn't allow any other type of windows installation than erasing the hard disk.

2. Some portion of the hard disk is failing but the linux portion is still working and the hard disk needs to be replaced.

3. You are going to relinquish the ownership (like you are going to sell it or give it to a relative) and you need to backup all your data and installed softwares before you give it to someone else.

4. The linux portion is broken but the partition is still accessible from a live dvd/cd/usb.

5. You are going to upgrade your system to a newer release and want to install the same bundle of softwares in your new system. In this case, if your /home is in a different partition, you only need software backup.

6. You are going to treat you system as guinea pig for some dangerous experiment and the system contains valuable information that you don't want to loose.

7. There are many more unexpected situations in which you may need a system backup.

#1. Personal Data Backup:

All of your personal data are stored in /home/user directory. user is your user name. That means you just need to copy it somewhere safe. So copy them in an external hard drive and copy it back in your new system. One thing that is recommended in this respect is that, you need to use the same username as your previous one, because otherwise, different usernames will conflict with the config files of some softwares and you will face some unfavourable situations with them.

If you are going to upgrade your system to a newer release or going for a different version and /home & root is in the same partition then the best option is to copy only your personal data like downloads, videos, pictures, music, documents, desktop and only the files that you know that it's valuable and exclude other file/folders i.e almost everything will be excluded that starts with a .(dot) in the begining of their name. But some of this hidden files may be backed up for special purposes like .mozilla, .cache etc that contains your firefox bookmarks, passwords etc.

If you are getting some error message telling you that you don't have the permissions, then it means you were going to copy/backup some files/folders that is owned by root. If you yourself didn't created some files/folders like that then you don't need to copy them at all, you can ignore/skip them. And if you created some files/folders like that to prevent easy deletion/access then you already know what to do to copy them i.e you need to open them with root privilege. right click on that folder (if it's a file then right click inside the file containing folder) and select "open as root". now you will be able to access them and do whatever's needed.

#2. Software Backup:

1. Getting a list of manually installed softwares:

1.1 With synaptic:

First generate a list that contains all of your software names. For this, open synaptic package manager. You will see some options saying "sections", "status", "origin", "custom filter", "search filter" at left. click on "status".

Then above this field you will see some more options. Among them choose "installed (manually) if you are going to install the same version of LM again or choose "installed" if you are going for another version of LM.

now select one of the software from the software list at right and press Ctrl+A, that will select all of them.

now right click on any of them and select "mark for reinstall".

go to "File" option and select "save markings" and save the file with a name like softs.list and keep it in a safe place.

1.2 From terminal:

Run this command to get the softs.list from a terminal:

sudo dpkg --get-selections | grep -v deinstall >softs.list

keep the softs.list in a safe place.

2. Installing packages from the saved list:

In your new system the first thing that you must do is to run the code:

sudo apt-get update

or in synaptic click the option that says "reload"

then in synaptic go to "File" option and select "read markings" and then click "apply". All of your softwares will be back in your new system.

If you prefer a terminal way then run this command (after running sudo apt-get update):

sudo dpkg --set-selections < softs.list #path/to/softs.list
sudo apt-get -u dselect-upgrade


Additional Info:

If you are going to reinstall the same system over again for a peculiar situation then you can avoid downloading the softwares over again in the new system if you have kept your downloaded packages somewhere safe beforehand. The downloaded packages are kept in the directory /var/cache/apt/archives/ and the lists are kept in /var/lib/apt/lists/. So you need to copy them (all in /var/cache/apt/ and /var/lib/apt/lists/) and keep them somewhere safe and in new system copy them back and use the softs.list and synaptic to install them again. If you are going through this process then one thing that is recommended is to check the check box that says "leave all downloaded packages in the cache" in synaptic in settings->preference->files (tab) always. This will keep the packages unharmed in the /var/cache/apt/archives directory.

jahid_0903014 7 years ago

I have added a terminal way to get the softs.list and install from it.

Uncle_Snail 7 years ago

Great article! However, do you know a way get a `softs.list` from the programs on a broken system, that I can't open synaptic in? I can still get to all the files, and even run the command line, but anything with a gui crashes. (I have tried for days, and can't find a way to restore the programs I had from a broken system.)
Thanks, Uncle Snail

jahid_0903014 7 years ago

You just copy them, and in your new system put them back in their places.

dickheijkoop 7 years ago

Hi, thanks for this tutorial! How about changes made outside the home directory, like fstab for NAS, printer config, etc.? I need to move to new PC and want to have my current install (17.2) back with minimum efforts. Thanks, Cheers Dick

pixiechris 8 years ago

The 'Additional Info' is what I have been looking for for quite a while now, thanks.