Backup and Restore of Manually Installed APT Packages
Backup and Restore of Manually Installed APT Packages
This documentation describes how to save and restore manually installed APT packages on a Debian-based system.
It uses the apt-mark showmanual command to generate a clean list of user-installed packages, which can be used to restore or clone systems.
Overview
A list of manually installed packages is created and stored at:
/etc/apt/packages.listThis file is overwritten each time the backup tool is executed.
/etc/apt/sources.list
- https://docs.hetzner.com/de/robot/dedicated-server/operating-systems/hetzner-aptitude-mirror/
- ai netselect-apt; netselect-apt
- /etc/apt/sources.list
- apt edit-sources
dist upgrade
- cat /etc/apt/preferences; cat /etc/apt/preferences.d/*
- apt-cache policy
- ai apt-listchanges deborphan
for pkg in $(deborphan); do
aptitude why "$pkg"
done- apt remove --purge $(deborphan)
- apt list --installed
- apt-mark showhold
lxc_package_install.sh
#!/bin/bash
# =============================================================================
# Script Name: lxc_package_install.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script installs a specified package in all running LXC
# containers.unattended-upgrades
ai unattended-upgrades apt-utils
/etc/apt/apt.conf.d/50unattended-upgrades
- "site=download.opensuse.org";
- "site=deb.nodesource.com";
- "site=download.jitsi.org";
- "Docker:${distro_codename}";
backup installed packages
backup
- dpkg --get-selections > dpkg.txt
restore
- dpkg --clear-selections
- dpkg --set-selections < dpkg.txt
- apt-get autoremove
- apt-get dselect-upgrade