How to Back Up & Restore Installed Packages on Ubuntu

How to Back Up & Restore Installed Packages on Ubuntu (Complete Step-by-Step Guide)

Reinstalling Ubuntu or migrating to a new system often means reinstalling dozens, sometimes hundreds of applications. Doing this manually can be time-consuming and error-prone. Fortunately, Ubuntu provides built-in tools that make it easy to preserve your software environment.

In this guide, you’ll learn how to back up & restore installed packages on Ubuntu using native package management tools like dpkg and apt. This approach is reliable, lightweight, and doesn’t require third-party software.

Whether you’re preparing for a clean OS reinstall, setting up a new machine, or maintaining multiple Ubuntu systems, this method ensures you can quickly restore your applications with minimal effort.

Why Backing Up Installed Packages on Ubuntu Matters

Backing up installed packages is not the same as backing up personal files. Instead, it creates a snapshot of:

  • All applications installed via APT and .deb packages
  • System utilities and dependencies
  • Software installed from official repositories and PPAs

his does not include software installed via Snap or Flatpak; those require separate backup steps.

This is especially useful if you:

  • Plan to reinstall Ubuntu
  • Upgrade to a newer Ubuntu version
  • Want identical software setups across multiple systems
  • Need fast recovery after system failure

Understanding how to back up & restore installed packages on Ubuntu saves time and prevents forgotten dependencies.

Understanding the Tools Used

Ubuntu uses the Debian package management system. Two tools are central to this process:

  • dpkg – Handles low-level package installation and package state tracking
  • apt – Downloads and installs packages from repositories

Together, these tools allow you to export a list of installed packages and later reinstall them automatically.

How to Back Up Installed Packages on Ubuntu

Open the terminal and run:

dpkg --get-selections > installed-packages.list
sudo apt-mark showmanual > manual-packages.list

This command generates a plain text file containing all installed packages and their states. The file can be stored anywhere, but it’s best to keep it in a safe external location such as:

  • A USB drive
  • Cloud storage
  • Another disk partition

To verify the file:

cat installed-packages.list
cat manual-packages.list

This file is the foundation of restoring your system later.

Knowing how to back up & restore installed packages on Ubuntu isn’t complete without backing up software sources.

Many users install software from:

  • PPAs
  • Vendor repositories (Chrome, Docker, VS Code, etc.)

Without these sources, Ubuntu won’t be able to locate some packages during restoration. Run the following commands:

mkdir ~/repo-backup
sudo cp -r /etc/apt/sources.list* ~/repo-backup/
sudo cp -r /etc/apt/trusted.gpg* ~/repo-backup/
sudo cp -r /etc/apt/keyrings ~/repo-backup/

This backs up:

  • Official repository lists
  • Third-party repositories
  • Authentication keys

How to Restore Installed Packages on New Ubuntu System

First we need to copy the backed up installed-packages.list and manual-packages.list files from old system to new system.

scp /path/to/installed-packages.list /path/to/manual-packages.list username@new_system_ip:/destination/path/

Copy the repo configurations to the new server.

sudo scp ~/repo-backup/* username@new_system_ip:/etc/apt/sources.list.d/
sudo apt update

Restore package selections:

sudo dpkg --set-selections < installed-packages.list
sudo apt-get dselect-upgrade

Restore only manually installed packages (cleaner):

sudo xargs apt install -y < manual-packages.list

If both machines are Ubuntu 24.04 with identical repositories, you’ll get the same package versions.

Final Thoughts

Learning how to back up & restore installed packages on Ubuntu is a powerful skill that saves time, reduces frustration, and improves system reliability. With just a few terminal commands, you can recreate your entire software environment on any Ubuntu installation.

This approach is:
✔ Built-in
✔ Stable
✔ Distribution-friendly
✔ Google-approved best practice

Leave a Reply

Your email address will not be published. Required fields are marked *