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 <command> [options] [arguments]
apt-clone clone <output-directory>
apt-clone restore <archive-file.apt-clone.tar.gz>
PARAMETERS
clone <output-directory>
Clones the current system's APT configuration and installed packages into the specified directory. This directory will contain the .apt-clone.tar.gz archive.
restore <archive-file.apt-clone.tar.gz>
Restores APT packages and configuration from the specified apt-clone archive file.
-h, --help
Displays a help message and exits.
-v, --version
Shows the program's version number and exits.
--force
During restore, force overwriting of existing files or configurations without prompting.
--dry-run
Performs a simulation of the restore operation, showing what packages would be installed or removed without making any actual changes to the system.
--with-dpkg-repack
When cloning, also uses dpkg-repack to save .deb files for all currently installed packages into the archive. This can create very large archives.
--savelog
When cloning, saves the APT history logs (/var/log/apt/history.log and /var/log/apt/term.log) into the archive.
--save-pkgs
Explicitly saves the list of installed packages. This is the default behavior for the clone command.
--restore-src
During restore, recreates sources.list.d entries from the archive, configuring APT repositories.
--restore-etc-apt
During restore, restores the entire /etc/apt directory from the archive. This includes all configuration files and repository definitions.
--restore-dpkg-statoverrides
During restore, restores dpkg-statoverrides from the archive, which can modify file permissions and ownership for certain installed packages.
--restore-debs
During restore, installs .deb files that were saved with --with-dpkg-repack during the clone operation. This allows offline package installation if the packages are available in the archive.
--auto-install-pkgs
During restore, automatically installs missing packages listed in the archive. This is the default behavior for the restore command.
--dont-check-gpg
During restore, disables GPG signature checking for repositories. Use with extreme caution as this can compromise system security by allowing installation of untrusted packages.
--destination <directory>
Specifies the destination directory for the cloned data. For the clone command, this is where the .apt-clone.tar.gz file will be created.
--tempdir <directory>
Specifies a temporary directory to be used for intermediate operations during cloning or restoring.
--assume-yes
Automatically answers 'yes' to all prompts during the operation, making it non-interactive.
DESCRIPTION
apt-clone is a utility designed to create a backup of installed APT packages and repository information from one system, allowing for easy restoration on another system or the same system after a fresh install. It captures the list of currently installed packages, the APT sources (repositories), and any authentication keys associated with them.
This makes it efficient for migrating package selections between machines or for setting up new systems with a similar software environment without manually reinstalling each package. During the clone operation, it creates a tarball (typically named
CAVEATS
- apt-clone primarily manages APT package selection and repository configurations. It does not back up or restore application-specific configuration files located outside of /etc/apt. For a full system backup, other tools are necessary.
- Using the --with-dpkg-repack option can generate extremely large archive files, especially on systems with many installed packages. Ensure sufficient disk space.
- Restoring an apt-clone archive on a significantly different distribution version or architecture might lead to dependency issues or package conflicts. It works best between identical or very similar systems.
- The --dont-check-gpg option disables critical security checks and should only be used in controlled environments with full understanding of the risks.
- A network connection is required during the restore operation to download packages that are not present in the archive (unless --restore-debs is used and the packages are in the archive).
ARCHIVE CONTENTS
A typical .apt-clone.tar.gz archive created by apt-clone usually contains:
- pkgs.txt: A plain text file listing all manually installed packages on the source system.
- sources.list.d/: A directory containing the .list files that define additional APT repositories.
- trusted.gpg.d/: A directory with GPG public keys used to authenticate packages from added repositories.
- repack/: (Only if --with-dpkg-repack was used) A directory containing the .deb files for all installed packages.
COMMON USE CASES
apt-clone is particularly useful for:
- System Migration: Easily transferring your installed software environment from an old machine to a new one.
- OS Reinstallation: Quickly restoring your preferred applications after a fresh operating system installation.
- Environment Replication: Setting up multiple development or testing machines with an identical set of packages and repositories.
- Backup: Creating a point-in-time backup of your system's software configuration.
HISTORY
apt-clone was originally developed as part of the ubuntu-tweak project, a popular configuration utility for Ubuntu. Its utility in simplifying system migration and replication led to its adoption as a standalone tool, often included in official repositories of Debian-based distributions like Ubuntu. It provides a more specialized and convenient way to manage package environments compared to manual methods involving dpkg --get-selections and dpkg --set-selections.
SEE ALSO
apt(8), dpkg(1), dpkg-repack(1), apt-mark(8), etckeeper(1)