Downgrade all Debian packages to a specific date
Unlike NixOS, Debian doesn’t have a builtin mechanism to rollback an installation to a specific point in time. However, thanks to snapshot.debian.org, a wayback machine for Debian packages, it is possible to downgrade all packages to the versions from a chosen date.
Let’s suppose we want to go back to January, 20th 2020. In
/etc/apt/sources.list.d/snapshot.list, we add a date-specific
snapshot as a source:
deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20200120T111800Z/ unstable main contrib non-free
In /etc/apt/preferences.d/snapshot.pref, we set the priority of all
packages from this source to 1001. This is above the default priority
of 500 and over 1000 to allow downgrade. See apt_preferences(5)
manual page for more details.
Package: * Pin: origin snapshot.debian.org Pin-Priority: 1001
After running apt update, we can check the result with apt policy:
$ apt policy Package files: 100 /var/lib/dpkg/status release a=now 1001 https://snapshot.debian.org/archive/debian/20200120T111800Z unstable/non-free amd64 Packages release o=Debian,a=unstable,n=sid,l=Debian,c=non-free,b=amd64 origin snapshot.debian.org 1001 https://snapshot.debian.org/archive/debian/20200120T111800Z unstable/contrib amd64 Packages release o=Debian,a=unstable,n=sid,l=Debian,c=contrib,b=amd64 origin snapshot.debian.org 1001 https://snapshot.debian.org/archive/debian/20200120T111800Z unstable/main amd64 Packages release o=Debian,a=unstable,n=sid,l=Debian,c=main,b=amd64 origin snapshot.debian.org […]
When requesting an upgrade, we Continue reading
