Problem/Motivation

An archive job can only be created in the user interface (Content » E-Arkiv » Create archive). drush earkiv:process only processes jobs that already exist. This makes it hard to:

  • start an archive from a script, a deployment or a server cron job;
  • archive a test or local copy of a site with other settings than the defaults.

There is also no way to stop a running job. Pressing Ctrl+C or killing the process leaves the job marked as running. It is then resumed by the next earkiv:process once the lock has expired, and its working directory stays in the temporary directory.

Proposed resolution

drush earkiv:create creates an archive job with the default settings from the settings page. The settings can be overridden with options:

  • --url, --connections, --sitemap / --no-sitemap, --exclude=PATTERN and --start-url=URL (both repeatable) for the HTTrack archiver;
  • --storage-path for the local storage;
  • --process to create and process the new job right away, both creating the archive and moving it to storage, with the same resume attempts as cron.

The values are validated with the same plugin validation as the form.

drush earkiv:cancel ID cancels a job:

  • It sets a new status, "Cancelled". Cancelled jobs are never picked up by earkiv:process.
  • The process working on the job checks the status every 5 seconds. When the job is cancelled it stops HTTrack or tar, removes the working directory and any unstored archive, and releases the lock. This also works when the job runs on another web server.
  • If no process reacts within 15 seconds, for example because it already died, the command cleans up itself.
  • A job that is being moved to storage cannot be cancelled, so the stored archive is never left half copied.

Remaining tasks

  • Implement and test.
  • Review.

User interface changes

New status "Cancelled" in the archive list. New Drush commands earkiv:create and earkiv:cancel.

API changes

New constant ArchiveStatusEnum::CANCELLED.

Data model changes

None. The status field gets one more possible value.

AI-Generated: Yes (Used Claude Code to draft this issue and write the merge request.)

Issue fork earkiv-3636593

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thomas alsén created an issue. See original summary.

  • thomas alsén committed a797230c on 1.0.x
    feat: #3636593 Add Drush commands to create and cancel archive jobs
    
thomas alsén’s picture

Status: Active » Fixed

Merged into 1.0.x!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.