Skip to content

Instantly share code, notes, and snippets.

@epcim
Created February 6, 2018 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epcim/eceaa49c9578c3591a77453635f85cb8 to your computer and use it in GitHub Desktop.
Save epcim/eceaa49c9578c3591a77453635f85cb8 to your computer and use it in GitHub Desktop.
ubuntu debian backup restore packages
#A quick way of backing up a list of programs is to run this:
dpkg --get-selections > ~/Package.list
sudo cp -R /etc/apt/sources.list* ~/
sudo apt-key exportall > ~/Repo.keys
#It will back them up in a format that dpkg can read* for after your reinstall, like this:
sudo apt-key add ~/Repo.keys
sudo cp -R ~/sources.list* /etc/apt/
sudo apt-get update
sudo apt-get install dselect
sudo dselect update
sudo dpkg --set-selections < ~/Package.list
sudo apt-get dselect-upgrade -y
#You may have to update dpkg's list of available packages or it will just ignore your selections (see this debian bug for more info). You should do this before sudo dpkg --set-selections < ~/Package.list, like this:
apt-cache dumpavail > ~/temp_avail
sudo dpkg --merge-avail ~/temp_avail
rm ~/temp_avail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment