E-Arkiv archives a Drupal site as a static copy that can be opened without Drupal, for example to meet the rules for archiving the websites of Swedish public authorities. The archive is a .tar.gz file with the pages and files of the site, a start page, a description of how it was made, checksums and reports of what was missing.

Features

  • Complete crawls with HTTrack. Starts from the site, its sitemap.xml, extra start URLs and, optionally, every published node that anonymous users may view, so that pages no other page links to are archived too. Rabbit Hole settings are respected.
  • Fast. Up to 128 simultaneous connections. A site with about 7,800 URLs and 2.4 GB is archived in about 13 minutes.
  • Alternative host names. Links written as full URLs to the production host, or to the site name without www, point to the archived files when a copy of the site is archived.
  • Exclude patterns for filters, sorting and other pages that only repeat content.
  • Broken links stay usable. Error pages are replaced with a notice in the archive, and the archive lists broken links, published pages that no other page links to, and published pages that return an error.
  • Self-describing archives. Every archive has a start page, earkiv-manifest.json with the URL, times, settings and versions used, SHA-256 checksums of every file, and a checksum of the archive file itself.
  • Schedules with iCalendar recurrence rules, for example every Sunday at 02:00.
  • Reliable jobs. Interrupted crawls are resumed, failed jobs can be retried, and progress is shown in the archive list and in Drush.
  • Drush commands to create, process, retry, cancel and follow jobs.
  • Pluggable. Archivers and storage are plugins. The module ships with the HTTrack archiver and storage in the private file system.

What is in an archive

Each archive is a file named like earkiv_12_1794334164.tar.gz. When it is extracted, it contains:

File Contents
index.html The start page of the archive: which site was archived and when, a link to the start page of the archived site, and links to the files below.
www.example.com/ The archived pages and files, one directory per host, with the links between them pointing to the local files.
earkiv-manifest.json A description of the archive: the job, the archived URL, when the crawl started and finished, the versions of E-Arkiv, Drupal and HTTrack, all archiver settings (including the exclude patterns), the numbers of URLs, files, bytes, broken links, unlinked pages and published pages with errors, the path of the start page and the list of reports.
earkiv-checksums.sha256 The SHA-256 checksum of every file in the archive, in the format of sha256sum. sha256sum -c earkiv-checksums.sha256 verifies an extracted archive.
earkiv-broken-links.csv Links that returned an error when the site was archived: the HTTP status, the URL and the page that links to it. The archive shows a notice in place of each missing page.
earkiv-unlinked-pages.csv Published pages that no other page links to, with node ID, language, content type, title, URL and archived file. Only when all published content is included.
earkiv-published-errors.csv Published pages that returned an error, with node ID, language, content type, title, URL and HTTP status, for example because of a + in the path alias. Only when there are such pages.
hts-log.txt The log of HTTrack.
hts-cache/new.txt Every crawled URL with its HTTP status, MIME type, local file and referring page.

The SHA-256 checksum of the .tar.gz file itself is shown in the archive list and stored next to the archive as earkiv_….tar.gz.sha256, which sha256sum -c also reads.

Requirements

  • Drupal 11.2 or later, or Drupal 12.
  • The command line tools httrack, tar and gzip on the server. In DDEV, add webimage_extra_packages: [httrack] to .ddev/config.yaml.
  • A private file system for the archives.
  • Drush, to run the archive jobs.

Getting started

  1. Install the module: composer require 'drupal/earkiv:^1.0@beta' and drush en earkiv.
  2. Configure the URL of the site and the other settings at Configuration › Web services › E-Arkiv (/admin/config/services/earkiv).
  3. Create an archive at Content › E-Arkiv (/admin/content/earkiv), or with drush earkiv:create --process.
  4. Run drush earkiv:process from the server's cron, for example every five minutes, so that jobs and schedules are processed.

The README describes every setting, the Drush commands and recommendations for production servers.

Credits

Inspired by the Lullabot article on retiring a Drupal site with HTTrack by Karen Stevenson (KarenS).

Supporting organizations: 

Project information

Releases