Skip to content

Instantly share code, notes, and snippets.

@KRTirtho
Forked from kozmonaut/linux-packages
Created April 16, 2025 14:14
Show Gist options
  • Save KRTirtho/62af5aa79d2feb090432851318552c66 to your computer and use it in GitHub Desktop.
Save KRTirtho/62af5aa79d2feb090432851318552c66 to your computer and use it in GitHub Desktop.
Backup and restore installed packages inside Linux Debian
# Backup your packages list
# Get a packages list
dpkg --get-selections > ~/Package.list
# Copy list of repositories
sudo cp /etc/apt/sources.list ~/sources.list
# Export repo keys
sudo apt-key exportall > ~/Repo.keys
# Restore packages
sudo apt-key add ~/Repo.keys
sudo cp ~/sources.list /etc/apt/sources.list
sudo apt-get update
sudo apt-get install dselect
sudo dpkg --set-selections < ~/Package.list
sudo apt-get dselect-upgrade -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment