apt-clone
Clone installed APT packages to another system
TLDR
Clone the package state of the current system into a specified directory
Create a clone file (.tar.gz) for backup purposes
Restore the package state from a clone file
Show information about a clone file (e.g., the release, architecture)
Check if the clone file can be restored on the current system
SYNOPSIS
apt-clone save [options...] clone-file.tar.gz
apt-clone restore [options...] clone-file.tar.gz
PARAMETERS
-d, --destdir=DIR
Destination directory for clone file (default: /var/spool/apt-clone/)
-s, --source-only
Clone only APT sources, skip packages
--help, -h
Show help message
--version
Display version information
-q, --quiet
Reduce output verbosity
--skip-running
Skip if another APT/DPKG process is running (restore only)
--no-update
Skip apt-get update before restore
--allow-unauthenticated
Allow unauthenticated packages during restore
--simulate, -S
Simulate actions without changes (restore only)
DESCRIPTION
apt-clone is a utility for Debian-based distributions like Ubuntu, used to backup and restore the complete APT package manager state. It captures installed packages, package selections, repositories from /etc/apt/sources.list and /etc/apt/sources.list.d/, GPG keys, preferences, and held packages into a compressed tarball. This allows seamless replication of software environments across identical systems, ideal for server provisioning, VM cloning, or quick recovery.
In save mode, it reads from /var/lib/dpkg/status and related files, excluding user data or configs. The restore mode updates repositories, simulates package changes, holds extraneous packages, and installs missing ones via apt-get. It ensures architecture and release compatibility, preserving exact versions where possible.
Requires root access and matching distro versions for best results. Handles pinned and auto-installed flags accurately, minimizing reconfiguration time.
CAVEATS
Must run as root. Assumes same distro release/architecture; mismatches cause failures. Does not clone /etc configs or user data. Tarball may be large for many packages.
BASIC USAGE EXAMPLE
sudo apt-clone save ~/backup.tar.gz
Transfer file, then on target: sudo apt-clone restore ~/backup.tar.gz
System will update repos and install matching packages.
SOURCES ONLY
sudo apt-clone save -s ~/sources.tar.gz
Clones repositories/keys without packages; useful for repo syncing.
HISTORY
Developed by Stefano Zacchiroli around 2008 for Debian/Ubuntu. Packaged in apt-clone since Ubuntu 9.04 (Jaunty). Maintained in Debian repos; latest versions improve key handling and multi-arch support.
SEE ALSO
apt-get(8), dpkg(1), apt(8), debootstrap(8)


