TranslateProject/sources/tech/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md
darksun a31e49386d 选题: 20190505 apt-clone : Backup Installed Packages And Restore Those On Fresh Ubuntu System
sources/tech/20190505 apt-clone - Backup Installed Packages And Restore Those On Fresh Ubuntu System.md
2019-05-05 10:27:09 +08:00

4.3 KiB
Raw Blame History

apt-clone : Backup Installed Packages And Restore Those On Fresh Ubuntu System

Package installation is become more easier on Ubuntu/Debian based systems when we use apt-clone utility.

apt-clone will work for you, if you want to build few systems with same set of packages.

Its time consuming process if you want to build and install necessary packages manually on each systems.

It can be achieved in many ways and there are many utilities are available in Linux.

We have already wrote an article about Aptik in the past.

Its one of the utility that allow Ubuntu users to backup and restore system settings and data

What Is apt-clone?

apt-clone lets allow you to create backup of all installed packages for your Debian/Ubuntu systems that can be restored on freshly installed systems (or containers) or into a directory.

This backup can be restored on multiple systems with same operating system version and architecture.

How To Install apt-clone?

The apt-clone package is available on Ubuntu/Debian official repository so, use apt Package Manager or apt-get Package Manager to install it.

Install apt-clone package using apt package manager.

$ sudo apt install apt-clone

Install apt-clone package using apt-get package manager.

$ sudo apt-get install apt-clone

How To Backup Installed Packages Using apt-clone?

Once you have successfully installed the apt-clone package. Simply give a location where do you want to save the backup file.

We are going to save the installed packages backup under /backup directory.

The apt-clone utility will save the installed packages list into apt-clone-state-Ubuntu18.2daygeek.com.tar.gz file.

$ sudo apt-clone clone /backup

We can check the same by running the ls Command.

$ ls -lh /backup/
total 32K
-rw-r--r-- 1 root root 29K Apr 20 19:06 apt-clone-state-Ubuntu18.2daygeek.com.tar.gz

Run the following command to view the details of the backup file.

$ apt-clone info /backup/apt-clone-state-Ubuntu18.2daygeek.com.tar.gz
Hostname: Ubuntu18.2daygeek.com
Arch: amd64
Distro: bionic
Meta: libunity-scopes-json-def-desktop, ubuntu-desktop
Installed: 1792 pkgs (194 automatic)
Date: Sat Apr 20 19:06:43 2019

As per the above output, totally we have 1792 packages in the backup file.

How To Restore The Backup Which Was Taken Using apt-clone?

You can use any of the remote copy utility to copy the files on remote server.

$ scp /backup/apt-clone-state-ubunt-18-04.tar.gz Destination-Server:/opt

Once you copy the file then perform the restore using apt-clone utility.

Run the following command to restore it.

$ sudo apt-clone restore /opt/apt-clone-state-Ubuntu18.2daygeek.com.tar.gz

Make a note, The restore will override your existing /etc/apt/sources.list and will install/remove packages. So be careful.

If you want to restore all the packages into a folder instead of actual restore, you can do it by using the following command.

$ sudo apt-clone restore /opt/apt-clone-state-Ubuntu18.2daygeek.com.tar.gz --destination /opt/oldubuntu

via: https://www.2daygeek.com/apt-clone-backup-installed-packages-and-restore-them-on-fresh-ubuntu-system/

作者:Magesh Maruthamuthu 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出