I'm currently running Ubuntu 20.04.4 LTS
.
Four times over the past year or two, my apt
database got screwed up somehow (I don't know how), and the next time I ran apt
, apt-get
, and aptitude
, I was told that I have more than 1,000 packages that are set up to be removed. If I did an autoremove
with the intention of later trying to reinstall, my entire system would have become unusable, because most of the normal, everyday programs would then have been removed during that autoremove
.
I did not (!!!) delete the top-level desktop package, nor any top-level package. This error occurred due to something (??? I don't know what) which somehow damaged the integrity of the apt
databases on my machine.
I was able to fix this each time by going through the procedure which I have outlined in the "Answer" to this question: Fixing broken apt **without** destroying my system via "apt autoremove"
However, the fact that this has occurred multiple times means that whatever caused this might cause it to happen again. In order to help fix this situation if/when it happens again, I'd like to know the following ...
What directories on my system should I back up if I want to preserve the state of the entire apt
system at any given time? I want to take periodic backups of all of these apt
-related directories, so that next time this error occurs, I could quickly restore my apt
environment by restoring all of these directories to their last backed-up versions.
Thank you for any pointers and suggestions as to what directories I should back up in order to preserve the integrity of my entire apt
environment.
aptitude
, since I use it for most of myapt
-related tasks. Occasionally,aptitude
hangs and crashes, perhaps due to intermittent network glitches during the time that it's running. I wonder if anaptitude
crash at the wrong moment might somehow end up corrupting theapt
database. In any case, if I could find out what are all of the directories which comprise thisapt
database, I could back them up and restore them whenever this might occur in the future. – HippoMan Jun 24 '22 at 15:42/var/lib/dpkg
. Could that be the only directory tree that I would need to back up and restore? I think there might be other package information somewhere else whichaptitude
uses, but I don't know where. – HippoMan Jun 24 '22 at 15:51apt
database, rather than try to useapt
-based ordpkg
-based utilities to fix a brokenapt
database. Those utilities are likely to also depend on the contents of this database, and if it's hosed, the utilities could also fail. – HippoMan Jun 24 '22 at 17:43