备份 apt包 并在全新安装的 Ubuntu 上恢复它们 (****)
如何在 Debian/Ubuntu/Kali 上重新打包 已安装的 软件 (****)
ubuntu迁移环境 软件包一键迁移 (****)
----------------------------------------------------------------------
apt-clone:debian官网,不能直接 apt安装,需要官网下载:
Debian -- Details of package apt-clone in sid
http://mirrors.ustc.edu.cn/debian/pool/main/a/apt-clone/apt-clone_0.4.3+nmu2_all.deb
dpkg -i apt-clone_0.4.3+nmu2_all.deb # 安装
-----------------------------------------------------------------------
关联参考:
Debian 中 apt-get 命令下载的软件在哪个目录下?
https://blog.csdn.net/ken2232/article/details/132504124
备份 apt包 并在全新安装的 Ubuntu 上恢复:apt-clone (****)
https://blog.csdn.net/ken2232/article/details/132501815
Linux的软链接具体如何使用?具体步骤是怎样的?
https://blog.csdn.net/ken2232/article/details/132504453
https://blog.csdn.net/sinat_36219858/article/details/114951318
-----------------------------------------------------------------------
apt-clone : /etc/apt/下的主要内容。只有几十 kb。
/var/cache/apt/archives : apt 下载的包放在这个 目录下,要备份这个,否则,重装需要重新下载,很浪费时间。
/var/cache/apt/ :
-----------------------------------------------------------------------
apt-clone 输出的压缩包内的文件:
var下的文件,为 apt-clone 专有的。
apt-clone只是备份 /etc/apt/下的主要内容:
-----------------------------------------------------------------------
参考:
备份 apt包 并在全新安装的 Ubuntu 上恢复它们 (****): apt目录下的 包
https://blog.csdn.net/ken2232/article/details/132501815
Debian 中 apt-get 命令下载的软件在哪个目录下?
https://blog.csdn.net/ken2232/article/details/132504124
怎样把ubuntu已安装的软件列表导出脚本好保存以后运行脚本直接安装原来想要的软件? (*****)
https://blog.csdn.net/ken2232/article/details/132495815
===========================================
备份 apt包 并在全新安装的 Ubuntu 上恢复它们 (****)
原名:备份安装的包并在全新安装的 Ubuntu 上恢复它们
在多个 Ubuntu 系统上安装同一组软件包是一项耗时且无聊的任务。你不会想花时间在多个系统上反复安装相同的软件包。在类似架构的 Ubuntu 系统上安装软件包时,有许多方法可以使这项任务更容易。你可以方便地通过 Aptik 并点击几次鼠标将以前的 Ubuntu 系统的应用程序、设置和数据迁移到新安装的系统中。或者,你可以使用软件包管理器(例如 APT)获取备份的已安装软件包的完整列表,然后在新安装的系统上安装它们。今天,我了解到还有另一个专用工具可以完成这项工作。来看一下 apt-clone
,这是一个简单的工具,可以让你为 Debian/Ubuntu 系统创建一个已安装的软件包列表,这些软件包可以在新安装的系统或容器上或目录中恢复。
apt-clone
会帮助你处理你想要的情况,
- 在运行类似 Ubuntu(及衍生版)的多个系统上安装一致的应用程序。
- 经常在多个系统上安装相同的软件包。
- 备份已安装的应用程序的完整列表,并在需要时随时随地恢复它们。
在本简要指南中,我们将讨论如何在基于 Debian 的系统上安装和使用 apt-clone
。我在 Ubuntu 18.04 LTS 上测试了这个程序,但它应该适用于所有基于 Debian 和 Ubuntu 的系统。
备份已安装的软件包并在新安装的 Ubuntu 上恢复它们
apt-clone
在默认仓库中有。要安装它,只需在终端输入以下命令:
$ sudo apt install apt-clone
安装后,只需创建已安装软件包的列表,并将其保存在你选择的任何位置。
$ mkdir ~/myaptpackages ## my_apt_packages
$ sudo apt-clone clone ~/mypackages
上面的命令将我的 Ubuntu 中所有已安装的软件包保存在 ~/mypackages
目录下名为 apt-clone-state-ubuntuserver.tar.gz 的文件中。
要查看备份文件的详细信息,请运行:
$ apt-clone info mypackages/apt-clone-state-ubuntuserver.tar.gz
Hostname: ubuntuserver
Arch: amd64
Distro: bionic
Meta:
Installed: 516 pkgs (33 automatic)
Date: Sat Sep 15 10:23:05 2018
如你所见,我的 Ubuntu 服务器总共有 516 个包。
现在,将此文件复制到 USB 或外部驱动器上,并转至要安装同一套软件包的任何其他系统。或者,你也可以将备份文件传输到网络上的系统,并使用以下命令安装软件包:
$ sudo apt-clone restore apt-clone-state-ubuntuserver.tar.gz
请注意,
- 此命令将覆盖你现有的
/etc/apt/sources.list
并将安装/删除软件包。 - 警告过你了!此外,只需确保目标系统是相同的 CPU 架构和操作系统。
- 例如,如果源系统是 18.04 LTS 64 位,那么目标系统必须也是相同的。
如果你不想在系统上恢复软件包,可以使用 --destination /some/location
选项将克隆复制到这个文件夹中。
$ sudo apt-clone restore apt-clone-state-ubuntuserver.tar.gz --destination ~/oldubuntu
在此例中,上面的命令将软件包恢复到 ~/oldubuntu
中。
有关详细信息,请参阅帮助部分:
$ apt-clone -h
或者手册页:
$ man apt-clone
建议阅读:
就是这些了。希望这个有用。还有更多好东西。敬请期待!
干杯!
发布于 2018-10-03 20:00
如何在 Debian/Ubuntu/Kali 上重新打包 已安装的 软件
How To Repack Installed Software on Debian/Ubuntu
It can happen that a particular version of a specific tweaked package no longer available elsewhere or you want the exact “clone” of the running software. If you have installed some Debian package on your server and want to install the same package on another server either to avoid downloading them again or “clone” with the settings then there are some tools which can help you. If the second machine lacks an internet connection then you’ll need to install the dependencies as well.
划重点:
1. 如何将 Debian系 Linux系统或服务器上已安装的软件重新打包,制作 deb 安装包;
2. 能否实现软件环境的克隆,以避免因缺失依赖而项导致的无法安装;
3. 保持软件原来的设置状态迁徙,减少后续重新设置时的工作量。
面对如上困境,博主推荐使用 dpkg-repack 和 apt-clone工具 ~~
一、 Dpkg-Repack
dpkg-repack 是一款能对已安装软件进行deb打包的软件。
Dpkg-Repack 软件的 Ubuntu 使用手册: https://manpages.ubuntu.com/manpages/kinetic/en/man1/dpkg-repack.1.html
在这里插入图片描述
安装方法:
sudo apt install dpkg-repack -y
在这里插入图片描述
安装成功后,以我 Kali Linux 操作系统中的 百度输入法为例:
打包百度输入法 Linux版:
dpkg-repack fcitx-baidupinyin
在这里插入图片描述
可以看到,在当前文件夹下,生成了名为 fcitx-baidupinyin_1.0.1.0_amd64.deb 的包,对,这是我使用了一年的老旧百度输入法,版本为 1.01,由此,证实 dpkg-repack 工具的确可将已安装的软件重新打包回 deb包。
如果由于任何权限问题而无法重建 deb 文件,请从fakeroot环境中运行命令:
fakeroot -u dpkg-repack <package-name>
我们可以在运行原始软件的主服务器上打印依赖项:
apt-cache depends Package_name |awk '{print $2}'
也可尝试创建脚本来自动安装依赖项:
package=package
dpkg-repack $(apt-cache depends --false-suggests $package |awk '{print $2}') $package
注意,dpkg-repack 是无法复制你对软件的自定义设置的。它仅能对某台Debian系的系统或服务器上的软件进行deb的打包重建。
或许有小伙伴想,要是能保持软件设置状态和依赖项移植过去就好了,这样就能顺利的安装,并节省重新设置的时间啦!!
不着急,热心帅气的博主已为你想好了方法~
一、Apt-Clone
apt-clone 是一款非常使用的程序,能够 帮助 dekg-repack 重新构建deb的同时保留被打包软件的设置项和依赖环境。
Apt-Clone 软件的 Ubuntu 使用手册: http://manpages.ubuntu.com/manpages/bionic/man8/apt-clone.8.html
在这里插入图片描述
Apt-Clone的 Debian 官网下载:https://packages.debian.org/stretch/apt-clone
在这里插入图片描述
当然,该软件同样可通过CLI进行安装:
apt-get install apt-clone -y
在这里插入图片描述
可以通过 apt 先查阅软件依赖项:
C:\root> apt-cache depends fcitx-baidupinyin | awk '{print $2}'
libc6
fcitx-bin
fcitx-data
fcitx-modules
libglib2.0-0
libqt5core5a
qml-module-qtquick-controls
fcitx
fcitx
在这里插入图片描述
指定构建被迁徙软件的 apt-clone.tar.gz 环境包:
apt-clone clone fcitx-baidupinyin --with-dpkg-repack
在这里插入图片描述
构建完成:在这里插入图片描述
最后将构建好的 apt-clone.tar.gz 移动到目标服务器中恢复构建即可:
apt-clone restore fcitx-baidupinyin.apt-clone.tar.gz
You can manually install the same packages from one server to another with the below commands :
dpkg -l | grep ^ii | awk '{print $2}' > installed
# another server
sudo apt-get install $(cat installed)
Usually, the settings are saved in the /etc/ directory. There are tools such as etckeeper which can be used with git to restore the settings :
http://etckeeper.branchable.com/
注:
Ubuntu的文档手册和 etckeeper 或许需要科学上网才可访问,但仍建议使用前先阅读。
另外, 该项过程将 耗费读者 较多的磁盘空间 和操作 时间,请耐心细致的去工作,并酌情处理~~
————————————————
版权声明:本文为CSDN博主「~晨曦静竹~」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_43515862/article/details/126457255
ubuntu迁移环境 软件包一键迁移 (****)
安装
sudo apt-get install apt-clone
原来机器备份:
sudo apt-clone clone backupname --with-dpkg-repack
备份到backupname 下,当前目录会生成一个tar包
查看包信息
apt-clone info backupname
Hostname: codewar-virtual-machine
Arch: amd64
Distro: bionic
Meta: libunity-scopes-json-def-desktop, ubuntu-desktop
Installed: 1625 pkgs (60 automatic)
Date: Tue Mar 24 22:40:42 2020
说明有1625个pkgs
新机器安装:
sudo apt-clone restore backupname
backupname 就是上面生成的tar包
————————————————
版权声明:本文为CSDN博主「勤奋的Alivon」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43619065/article/details/105083672