RackNerd Billboard Banner

How to Backup and Restore Installed Packages in Ubuntu

Keeping your Ubuntu system backed up is smart, but most people only think about files and forget the software they’ve installed. Reinstalling dozens (or hundreds) of packages manually after a fresh install is a headache. The good news: Ubuntu makes it easy to back up a list of installed packages and restore them later.

Here’s how you can do it.


Step 1: Backup Your Installed Packages

First, create a list of all the packages currently installed on your system.

Open a terminal and run:

dpkg --get-selections > package-list.txt

This command saves every installed package to a file called package-list.txt. You can move this file to a USB drive, external disk, or cloud storage.

If you also want to back up additional repositories (PPAs) you’ve added, export your sources list:

sudo cp -r /etc/apt/sources.list* ~/sources-backup/

Now you’ve got both the package list and repository info stored safely.


Step 2: Restore Your Package List

When setting up a new Ubuntu installation (or restoring your system), copy back your package-list.txt and sources backup.

  1. Restore your repositories:
    sudo cp -r ~/sources-backup/* /etc/apt/
    sudo apt update
  2. Restore your package list:
    sudo dpkg --set-selections < package-list.txt
    sudo apt-get dselect-upgrade

This tells Ubuntu to install everything from your saved package list.


Step 3: Verify and Clean Up

Not every package will install perfectly, especially if versions have changed or some packages are no longer available. After the restore, it’s a good idea to:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

This ensures your system is fully updated and cleans up leftover dependencies.


Bonus: Use apt-mark for Manual Packages Only

The dpkg method saves all packages, including dependencies. If you want to back up only the packages you explicitly installed (not the ones pulled in automatically), use:

apt-mark showmanual > manual-packages.txt

To restore later:

xargs sudo apt-get install -y < manual-packages.txt

This keeps your backup cleaner and avoids unnecessary bloat.


Final Thoughts

With just a couple of commands, you can safeguard your installed packages and save hours of work in case you need to reinstall Ubuntu. It’s a quick, lightweight backup method that pairs nicely with your regular file backups.

Set a reminder to update your package list every so often—especially before major upgrades—and you’ll always be covered.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link