Docs: CLI tools

Command-line tools

The three command-line tools tilspire ships with, for migrations, backups and updates, and a nightly schedule.

These scripts cover the tasks you might want to run by hand or from a scheduled task. The examples run from your site's root folder.

Scheduled jobs #

Since 1.15.0 tilspire has one runner for its regular jobs: email digests, off-site backups and their restore test, the search index, and clearing old chats and decided proposals. Run it every 5 minutes:

php core/cli/cron.php

It is optional. Since 1.17.1 the site runs its due jobs itself, from visits and from an open admin panel, and they also run whenever update.php --auto does. Off-site backups, email digests and automatic forum moderation are the exception: they run only from this runner or from update.php --auto, and the dashboard's health check says so, as it says when a job is overdue.

Migrations #

Applies any database migrations that haven't run yet: the core's first, then each enabled module's.

php core/cli/migrate.php
php core/cli/migrate.php --status

--status lists what's waiting without applying anything.

Backup #

Writes a content backup — your pages, posts, menus, redirects, content-model templates and settings — to site/backups/, and prunes old ones. Secret settings, such as your SMTP password, are left out unless you ask for them:

php core/cli/backup.php
php core/cli/backup.php --include-secrets

A backup made with --include-secrets holds credentials, so store it like one. Neither kind contains the key that decrypts two-factor secrets, which lives in site/config/config.php: keep a copy of that file with your backups, or members who use two-factor sign-in can't sign in to a restored site. The same file holds the key for your AI providers' keys (since 1.13.0); without it a restored site only asks for each provider key again.

For complete, encrypted copies stored away from the server, see Off-site backups; php core/cli/offsite.php opens and restores them.

Update #

php update.php
php update.php --apply
php update.php --auto
php update.php --undo

With no option, it only checks. --apply installs an available update. --auto does what the Automatic updates setting on the Updates page allows — the one to run from a scheduled task. --undo undoes the last update, as the Updates page does. Run it from the site's root folder: since 1.13.0 update.php sits there, so it works on Windows as well as Linux. Whenever it may change your site, it also applies any waiting migrations, the core's and each enabled module's.

Content sync #

On a staging site, sends its changes to production as drafts for a person to approve there, as System ▸ Content sync does:

php core/cli/sync.php

Install #

Installs tilspire without a browser, running the same steps as the setup wizard. See Installation.

php core/cli/install.php --help

A nightly schedule #

A typical crontab makes a backup first and updates afterwards:

15 3 * * * cd /path/to/site && php core/cli/backup.php
45 3 * * * cd /path/to/site && php update.php --auto
*/5 * * * * cd /path/to/site && php core/cli/cron.php