我需要运行一个可能破坏`apt-get`数据库的脚本。 我应该备份什么?

我正在研究rm的包装脚本,它可能会破坏apt-get部分处理方式。

如果apt-get数据库被破坏,我需要先备份哪些文件?

经过一番挖掘后,我发现apt-get数据库由dpkg管理

man dpkg

  /etc/dpkg/dpkg.cfg Configuration file with default options. /var/log/dpkg.log Default log file (see /etc/dpkg/dpkg.cfg(5) and option --log). The other files listed below are in their default directories, see option --admindir to see how to change locations of these files. /var/lib/dpkg/available List of available packages. /var/lib/dpkg/status Statuses of available packages. This file contains information about whether a package is marked for removing or not, whether it is installed or not, etc. See section INFORMATION ABOUT PACKAGES for more info. The status file is backed up daily in /var/backups. It can be useful if it's lost or cor‐ rupted due to filesystems troubles. 

它也是来自Debian常见问题解答

重要的是要理解aptitude或synaptic等更高级别的包管理工具依赖于apt本身依赖于dpkg来管理系统中的包。

因此,如果dpkg将自己的数据库放在/var/lib/dpkg/status ,这意味着apt-get数据库和dpkg维护的所有其他包管理器也将处于/var/lib/dpkg/status 。所以只需备份/var/lib/dpkg/status (其中dpkg已将其备份放在/var/backups/ )将解决您对使用apt-get担忧。