Reference Omeka S module

CLI Commands

The script is modules/Backup/bin/backup.php. Run it with the PHP CLI from any directory; it locates the Omeka root three levels above itself and bootstraps the application without handling an HTTP request.

php /var/www/omeka-s/modules/Backup/bin/backup.php <command> [options]

Run it as the web server user so that file permissions match the admin panel. Exit code 0 means success and 1 means failure. Progress messages go to standard output and errors to standard error, each prefixed with a timestamp.

create

Create a new backup and apply the retention limit afterwards.

php modules/Backup/bin/backup.php create [--no-db] [--no-files] [--no-api]
Option Effect
--no-db Skip the database dump
--no-files Skip the files/ directory
--no-api Skip the JSON-LD API export

Themes and modules are always included from the command line. The command prints the chosen options, then Backup complete: <filename> (<bytes> bytes). Because there is no logged-in user, the record's creator is empty (shown as cron in the admin list) and the API export contains only public resources.

list

Print every backup record, newest first.

php modules/Backup/bin/backup.php list

Columns are ID, Filename (truncated to 38 characters), Size in MB, Created At and Status. Prints No backups found. when the table is empty.

ZIP files in the backup directory that are not in the list follow under Not in the list, with their size and modification time. Add them with import.

cleanup

Delete complete backups beyond the Retention: keep last N complete backups setting, from disk and from the list.

php modules/Backup/bin/backup.php cleanup

restore

Restore a backup by its record ID (from list or the first column of the admin list).

php modules/Backup/bin/backup.php restore <id> [--no-db] [--no-files]
Option Effect
--no-db Do not restore the database
--no-files Do not restore the files/ directory

The command first prints the dry-run summary (the same What will happen list as the admin page), then prompts Type RESTORE to confirm (or anything else to abort). Anything other than RESTORE (case-insensitive) prints Aborted. and exits with code 0. Themes and modules are restored whenever the archive contains them; there is no option to skip them.

The checksum check, extraction and component handling are identical to a restore from the admin panel. See Restoring Backups.

import

Add archives copied into the backup directory (for example with FTP, SFTP or scp) to the list.

php modules/Backup/bin/backup.php import [<filename> ...]

With one or more filenames, adds those archives. A path is accepted as long as it points into the backup directory; a file anywhere else is refused, so move it there first. With no filename, adds every ZIP in the backup directory that is not in the list.

Each archive goes through the same checks as Add to backups on the Backups page: it must be a complete ZIP containing metadata.json, and every file inside it must match its stored CRC-32 checksum. The archive's SHA-256 checksum is recorded and it is listed as complete, with no background job. The command prints Added as backup #<id> with the matching restore command for each archive, or an error for any that fail, and exits with code 1 if any failed. An archive that fails the content check stays in the list as failed.

See Adding Archives by FTP.

fetch

Download an archive from a link into the backup directory, check it and add it to the list.

php modules/Backup/bin/backup.php fetch <url> [--allow-private]
Option Effect
--allow-private Allow a link to a private network address, such as another server on the same local network

The download runs in the command itself, with no background job, and prints the amount received every few seconds. It goes through the same steps as From a link on the Upload Backup page: it is tried again after a dropped connection, continuing where it stopped when the other server supports ranges, and the archive must be a complete ZIP containing metadata.json whose every file matches its stored CRC-32 checksum. The command prints Downloaded and checked: backup #<id> with the matching restore command, or an error, and exits with code 1 on failure. Deleting the archive from the list while it downloads stops the command.

See Downloading from a Link.

link

Print a download link for a complete backup, which another server (or anyone who has it) can download the archive from without signing in, for 48 hours.

php modules/Backup/bin/backup.php link <id> --site=<address>
Option Effect
--site=<address> Required. This site's address as visitors reach it, such as https://old.example.org: the command line cannot tell it.

The command prints the link and when it stops working. Making a link replaces any earlier link for the same backup. It exits with code 1 for a backup that is not complete or whose archive is not on this server.

unlink

Stop a backup's download link working at once.

php modules/Backup/bin/backup.php unlink <id>

See Download Links.

help

Any other command, or no command, prints the usage summary.

Requirements for CLI runs

  • The PHP CLI must be able to read config/database.ini and connect to the database, as the web application does.
  • The same zip extension requirement applies, and fetch needs the curl extension.
  • The script writes to the same backup directory and backup.log as the admin panel, so the running user needs write access there.
Log in for Support