-1

After I upgraded a package, when I ran apt-cache policy <package-name>, I saw that the previous version of this same package is not there in the list.

Before the bind9-dnsutils package was upgraded, cache list showed three different versions of this package:

$ apt-cache policy bind9-dnsutils
bind9-dnsutils:
  Installed: 1:9.16.1-0ubuntu2.8
  Candidate: 1:9.16.1-0ubuntu2.9
  Version table:
     1:9.16.1-0ubuntu2.9 500
        500 http://pl.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://pl.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
 *** 1:9.16.1-0ubuntu2.8 100
        100 /var/lib/dpkg/status
     1:9.16.1-0ubuntu2 500
        500 http://pl.archive.ubuntu.com/ubuntu focal/main amd64 Packages  

I performed bind9-dnsutils package upgrade to the latest version successfully. After package bind9-dnsutils is upgraded, when checked the cache list for this package is not showing the previous version 1:9.16.1-0ubuntu2.8 in the list.

$ sudo aptitude install bind9-dnsutils=1:9.16.1-0ubuntu2.9
bind9-dnsutils:
  Installed: 1:9.16.1-0ubuntu2.9
  Candidate: 1:9.16.1-0ubuntu2.9
  Version table:
*** 1:9.16.1-0ubuntu2.9 500
        500 http://pl.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://pl.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1:9.16.1-0ubuntu2 500
        500 http://pl.archive.ubuntu.com/ubuntu focal/main amd64 Packages

As a result if I try to downgrade to version 1:9.16.1-0ubuntu2.8 I get this error message:

Unable to find a version "1:9.16.1-0ubuntu2.8" for the package "bind9-dnsutils"
Unable to apply some actions, aborting

Is there a way to maintain the immediate previous version in the cache so, that I can rollback to it in case I have to do so?

karel
  • 114,770
  • I strongly suggest, for the sake of readibility, that you use the correct markdown formatting, especially for the code, rather than the HTML currently used – Greenonline Dec 06 '21 at 15:16
  • Edit your /etc/apt/apt.conf.d/20archive, and broaden the range of packages to be kept. – user535733 Dec 06 '21 at 15:18
  • You're talking about a backup and restore feature which has been part of Windows for a long time and since 20.04 you can install a package that adds this functionality to Ubuntu too. – karel Dec 07 '21 at 07:16
  • @user535733
    Thanks for quick reply. I tried two approaches broaden the range and also by disabled the archiving by putting zero value for each variable. Both approach didn't work

    Broaden the range

    APT::Archives::MaxAge "60";
    APT::Archives::MinAge "60";
    APT::Archives::MaxSize "1000";

    Disabled the operation

    APT::Archives::MaxAge "0";
    APT::Archives::MinAge "0";
    APT::Archives::MaxSize "0";

    Ubuntu Version details
    Distributor ID: Ubuntu
    Description: Ubuntu 20.04.3
    LTS Release: 20.04 Codename: focal

    Thanks Ani

    – user3737851 Dec 07 '21 at 08:01

1 Answers1

0

Congratulations on your rescue by apt from dependency hell. apt did what it's supposed to do in order to maintain correct package management that is necessary for installing, removing and upgrading software. If you want to add backup and restore functionality to Ubuntu that is similar to the System Restore feature in Windows install the timeshift package in Ubuntu 20.04 and later.

sudo apt update
sudo apt install timeshift

Timeshift is a system restore utility which takes snapshots of the system at regular intervals. These snapshots can be restored at a later date to undo system changes. Timeshift creates incremental snapshots using rsync or BTRFS snapshots using BTRFS tools.

On the other hand, maybe you don't want to install Timeshift because it's too heavy for when you just want to downgrade one package. If you can manage to manually dsownload bind9-dnsutils_9.16.1-0ubuntu2.8_amd64.deb and downgrade bind9-dnsutils without creating an unmet dependencies error, then you can prevent bind9-dnsutils from being upgraded by following the instructions in the answers to How to prevent updating of a specific package?. After you have downloaded bind9-dnsutils_9.16.1-0ubuntu2.8_amd64.deb you can check if it's installable without needing to install additional dependencies by running the following command:

apt install --simulate ./bind9-dnsutils_9.16.1-0ubuntu2.8_amd64.deb

The above command is just a simulation. It doesn't require sudo at the beginning, and it doesn't install anything or make any changes to your system.

karel
  • 114,770