1. Home
  2. Linux
  3. Clone your debian packages to a new system

Clone your Debian packages to a new system

Apt-clone is a simple tool that can scan your Debian Linux system for installed packages, software repositories, and third-party DEB packages and pack them away to install on another computer. Here’s how to use Apt-clone on your Linux system.

Before we begin

This guide uses Apt-Clone in Debian to back up previously installed software. However, Apt-Clone will also work on all Ubuntu distributions as well. If you use Ubuntu, Linux Mint, Zorin OS, etc., and want to use Apt-Clone, feel free to follow the instructions in this guide.

Installing Apt-Clone on Debian

The Apt-Clone tool doesn’t come pre-installed with Debian. So if you’d like to use it, you’ll need to install it on your computer. To install it, open up a terminal window. You can open a terminal window by pressing Ctrl + Alt + T on the keyboard.

Once the terminal window is open, run the apt install apt-clone command. If you’re on an older release of Debian, you may need to run apt-get install rather than apt install.

sudo apt install apt-clone

Upon entering the command above, Debian will ask you for a password. Using the keyboard, enter your user account password. Then, press the Y key to confirm that you wish to install the package.

With Apt-Clone installed on your Debian Linux PC, you can run the apt-clone –help command to view the help page. Reading the help page will help you familiarize yourself with all of the features Apt-Clone offers.

Creating a clone with Apt-Clone

Creating a clone with Apt-Clone is done in the terminal, as the program is terminal-based. To start, use the apt-clone clone command. This command tells the tool you wish to clone your current installation of Debian for later.

What does Apt-Clone “clone”? Package repositories (both first and third-party), GPG keys for repos, Apt preferences, and installed packages. Your entire Debian installation will be copied to an archive to restore later.

Using the apt-clone command below, create a clone package.

apt-clone clone my-debian-installation

The clone shouldn’t take too long to complete. When the process is finished, it will output a file in the home directory with the name. The file that Apt-Clone outputs will be in TarGZ format.

TarGZ is an archive format. However, it is insecure. If you want your Debian clone information from Apt-Clone kept secret, you can encrypt it with GPG. Here’s how.

First, ensure your installation of Debian has GnuPG installed. You can check this by entering the gpg –help command.

gpg --help

Assuming you have gpg installed, run the gpg -c command to encrypt the TarGZ archive. The encryption process will be quick. However, if you have a large clone file, it could take longer.

gpg -c my-debian-installation.tar.gz

Once the encryption is complete, you’ll have an output file with the name:


You can decrypt “my-debian-installation.tar.gz.gpg” with the following command.

gpg my-debian-installation.tar.gz.gpg

Creating a clone with Apt-Clone that includes manually installed packages

Running apt-clone clone will back up all of the packages installed on Debian through official software repositories. However, if you have third-party DEB packages you’ve downloaded from the internet that you wish to back up, you’ll need to do a different type of clone.

To back up third-party items, you must use the apt-clone –with-dpkg-repack. This command will scan for packages, not in the official repo and try to pack them away in the clone file.

apt-clone clone my-debian-installation --with-dpkg-repack

The –-with-dpkg-repack command-line switch for Apt-Clone takes considerably longer, especially if you have tons of third-party DEB packages. Sit back and be patient. When the process is complete, it will output “my-debian-installation.tar.gz.”

Want to encrypt your archive? Run the following gpg command.

gpg -c my-debian-installation.tar.gz

It should output “my-debian-installation.tar.gz.gpg”.

Restoring the Apt-Clone clone

Do the following to restore the Apt-Clone archive on a new Debian system. First, place “my-debian-installation.tar.gz” in your home folder on the latest Debian system. Then, if you’ve encrypted it, place “my-debian-installation.tar.gz.gpg” there instead.

After placing the file in the home directory, decrypt it (if necessary) using the gpg command down below.

gpg my-debian-installation.tar.gz.gpg

Once the file is decrypted, the restoration can begin. First, ensure you have the Apt-Clone tool installed. Then, use the apt-clone restore command. This command will restore all software repositories, previously installed packages, GPG keys, and even third-party DEB packages (if you choose to back them up during the cloning process).

sudo apt-clone restore my-debian-installation.tar.gz

The restoration process isn’t quick. It needs to move files around, re-install programs, and modify the system. Sit back, and allow the restoration process to run. Once the process is complete, close the terminal, and start using Debian!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.