Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Created February 12, 2022 09:44
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 hasinhayder/c41a22b7cab9f11fe1d12adaa91d3bca to your computer and use it in GitHub Desktop.
Save hasinhayder/c41a22b7cab9f11fe1d12adaa91d3bca to your computer and use it in GitHub Desktop.
Package Copy & Restore

https://askubuntu.com/posts/9889/edit

How to keep a list of all packages and restore using dpkg

  1. It'd be a good idea to just copy all of /home as that contains your documents and preferences. If you just want to know where preferences are stored, it varies. Many applications store them in .config (that's /home/username/.config) and .local. Most user preferences will be in .gconf. Some older applications might save settings in .gnome2. Firefox uses .mozilla; other browsers use .config as far as I know. To be safe, I'd just recommend backing up /home still.

  2. Run dpkg --get-selections > ~/my-packages.txt to build up a list of everything installed (or removed) on your system. It will be saved in your home folder as my-packages.txt. Once you reinstall, run sudo dpkg --set-selections < ~/my-packages.txt (assuming the file is placed in the same location again) and then sudo apt-get -u dselect-upgrade to start installing packages. You'll want to also back up /etc/apt/ and restore it on the new installation to ensure that any extra software you may have installed is still able to be installed again.

It sounds complicated (and boy does this post look weird with this formatting) but it's not too awful considering the alternative of installing everything by hand again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment