How to install packages using repository snapshot

It is rarely mentioned, but you can use repository snapshots to download and install old and obsolete packages on already unsupported or even current Debian distributions.

Snaphot creation date

I will use the latest available snapshot created before 2017-01-01 simply defined as 20170101.

$  curl -o /dev/null -s -L -w "%{url_effective}\n" http://snapshot.debian.org/archive/debian/20170101/
http://snapshot.debian.org/archive/debian/20161231T211634Z/

It will be snapshot created at 2016-12-31 21:16:34.

System configuration

Define system-wide repository snapshot.

$ cat << EOF | sudo tee /etc/apt/sources.list
deb     http://snapshot.debian.org/archive/debian/20170101/ jessie main contrib non-free
deb-src http://snapshot.debian.org/archive/debian/20170101/ jessie main contrib non-free
deb     http://snapshot.debian.org/archive/debian-security/20170101/ jessie/updates main contrib non-free
deb-src http://snapshot.debian.org/archive/debian-security/20170101/ jessie/updates main contrib non-free
EOF

Do not update package index at this moment. You will get the release file is expired error as the mentioned file is already invalid (Valid-Until entry).

$ sudo apt-get update
Hit http://snapshot.debian.org jessie Release.gpg
Get:1 http://snapshot.debian.org jessie/updates Release.gpg [1,554 B]
Hit http://snapshot.debian.org jessie Release
Hit http://snapshot.debian.org jessie/updates Release
E: Release file for http://snapshot.debian.org/archive/debian-security/20170101/dists/jessie/updates/Release is expired (invalid since 186d 22h 20min 18s). Updates for this repository will not be applied.

You need to ignore Valid-Until entry before running an update.

You can enforce this behaviour globally.

$ echo 'Acquire::Check-Valid-Until "false";' | sudo tee /etc/apt/apt.conf.d/00snapshot

You can enforce this behaviour on repository level if you use apt version 1.1.exp9 or newer available since Debian Stretch.

$ cat << EOF | sudo tee /etc/apt/sources.list
deb     [check-valid-until=no] http://snapshot.debian.org/archive/debian/20170101/ jessie main contrib non-free
deb-src [check-valid-until=no] http://snapshot.debian.org/archive/debian/20170101/ jessie main contrib non-free
deb     [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20170101/ jessie/updates main contrib non-free
deb-src [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20170101/ jessie/updates main contrib non-free
EOF

Update package index.

$ sudo apt-get update
Ign:1 http://snapshot.debian.org/archive/debian/20170101 jessie InRelease
Get:2 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates InRelease [63.1 kB]
Hit:3 http://snapshot.debian.org/archive/debian/20170101 jessie Release
Get:4 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/main Sources [174 kB]
Get:6 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/contrib Sources [1,439 B]
Get:7 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/main amd64 Packages [336 kB]
Get:8 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/main Translation-en [178 kB]
Get:9 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/contrib amd64 Packages [2,506 B]
Get:10 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/contrib Translation-en [1,211 B]
Fetched 757 kB in 0s (794 kB/s)                              
Reading package lists... Done

Verify the whole process.

$ apt-cache policy vim
vim:
  Installed: (none)
  Candidate: 2:7.4.488-7+deb8u1
  Version table:
     2:7.4.488-7+deb8u1 500
        500 http://snapshot.debian.org/archive/debian-security/20170101 jessie/updates/main amd64 Packages
     2:7.4.488-7 500
        500 http://snapshot.debian.org/archive/debian/20170101 jessie/main amd64 Packages

Additional information

You can specify desired snapshot more precisely by providing exact values for an hour, minute and second. For example 20170101T200000Z will return snapshot created at 2017-01-01 15:35:28.

$ curl -o /dev/null -s -L -w "%{url_effective}\n" http://snapshot.debian.org/archive/debian/20170101T200000Z/
http://snapshot.debian.org/archive/debian/20170101T153528Z/

Visit the snapshot archive at snapshot.debian.org

Check out the snapshot archive code at anonscm.debian.org/cgit/mirror/snapshot.debian.org.git/

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.

Gdansk, Poland https://sleeplessbeastie.eu