How to reinstall/upgrade with programs, repositories and keys kept

mercier
  14 years ago
  17

If you have a great working linuxmint distro, upgrading or reinstalling it means that you must reinstall all the additional programs, repositories and keys.

With lots of help from the community and google, here is my solution to automate and shorten the proces of reinstalling/upgrading.

All feedback is welcome, and if you have a better way - by all means share it with us.

Here is what you do:

You must have a separate /home partition.
Do not change your password, when reinstalling, it may cause weird issues upon reboot
.

1) Create APTonCD .iso file and place it in /home - no need to burn the cd, APTonCD can read from .iso (if it doesn't work from you, you can always burn the .iso and use a cd)

2) Create installed applications backup list:

sudo dpkg --get-selections > backup.log


Now you have created a text file in your home directory called backup.log

3) Backup downloaded repositories cache and repositories list:


sudo tar zcvf apt.tgz /etc/apt/ /var/lib/apt/ /var/cache/apt/


This creates apt.tgz in your home folder

4) Put your Mint LiveCD, boot and install Mint. Of course, do not format /home partition.

5) Boot into newly installed Mint.


6) To restore downloaded repositories cache and repositories list, make sure apt.tgz file is in your /home folder, and run:


sudo tar zxvf apt.tgz -C /



7) Start APTonCD and choose "restore" - choose the apton.iso file created earlier.
This will copy the previously downloaded files to your filesystem.

8) Open terminal in /home and run:


sudo dpkg --set-selections < backup.log


9) Supply your password if asked.

The next step requires a package that is not installed by default in LinuxMint/Ubuntu.

10) To install the program, type in the terminal:


sudo apt-get install dselect


Supply your password if asked.

Now all that is left is to type one last command into the terminal.

11) Now type:


sudo dselect


Supply your password if asked.

12) Now select 'install'.

You may have to click 'next' or 'ok'.

Once it is finished you can exit.

13) Now you are finished and you can use all of the programs you were using before we started this procedure.

Thanks to Midnighter, remoulder and Drew DeKoning

Comments
mercier 14 years ago

thanks guys for your input. i am currently waiting for my flight to go on...i will get back to you, hopefully soon.


clem 14 years ago

The file backup.log contains all the packages previously installed. What you really want, is the list of packages you "added" to Mint... not the ones that were already there before.. and not the ones that came as dependencies. So the process is a little more complicated that that. "apt search ~M" gives you a list of auto-installed packages. And you can make a list of what comes preinstalled from a VM. We've been working on this and the new mintBackup in Mint 9 will let you graphically backup and restore your software selection.


captainhaggy 14 years ago

For an upgrade, I simply exchange the "release names" in /etc/apt/sources.list and /etc/apt/sources.list.d/

deb http://packages.linuxmint.com/ isadora main upstream import backport
deb http://archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ lucid partner
deb http://packages.medibuntu.org/ lucid free non-free
deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu lucid main
deb http://tmw.cetki.com/mana lucid main

Then comes the next step ... doing
1) sudo apt-get update
to get tha list of all the actual packages and then ...
2) sudo apt-get dist-upgrade

It might happen, that you have to use once or twice
sudo apt-get install -f
or
sudo dpkg --configure -a
while upgrading that way, but in the end, you can reach your goal. It's not the way, I would recomend for beginneres, but advanced or professional linux users may go that way.

After it, you have the new version with updated software and all your datas in /home. Nothing changed, just the numbers of the used software packages ;)


RayWoods 14 years ago

There is one thing that I would add, renaming your home directory before installing the new edition of Mint. So in my case...

I rename /home/ray to /home/rayold
The new installation installs a new /home/ray
You can then either, delete the "new" /home/ray then rename /home/rayold back to /home/ray

or copy the contents (including hidden files) from /home/rayold to /home/ray