Backups
Heptapod backs itself up every day at 02:30 UTC. Each backup is a
password-encrypted ZIP with a PostgreSQL dump and the uploaded files, such as
client logos. Archives land on the backups volume of the same server.
A backup on the same server does not survive the loss of that server. Copy
archives elsewhere, or point BACKUP_DISK at S3-compatible storage.
See and start backups
Section titled “See and start backups”Owners see recent archives and the outcome of each run under Settings → Backups. They can also start a backup there. The app cannot restore a backup; restoring is a server task.
On the server:
dc() { docker compose --env-file .env.prod "$@"; }dc exec app php artisan backup:run --no-interactiondc cp app:/backups /srv/heptapod-backup-exportRestrict the export directory to its owner (chmod 700).
Keep the keys separately
Section titled “Keep the keys separately”A backup needs three things to be useful: the archive, BACKUP_ARCHIVE_PASSWORD
and every APP_KEY the instance used. Store .env.prod in a password manager or
another safe place, not only beside the archives.
Restore
Section titled “Restore”Restore onto a fresh instance with the same release, the same APP_KEY and the
same archive password, into an empty database. Never restore over live tables.
-
Stop the workers and enter maintenance mode:
shell dc stop horizon dispatcher schedulerdc exec app php artisan downdc cp /srv/restore/backup.zip app:/tmp/restore.zip -
Decrypt the archive inside the container. The password comes from the environment, not from your shell history:
shell dc exec app php -r '$z = new ZipArchive; if ($z->open("/tmp/restore.zip") !== true) { throw new RuntimeException("Cannot open archive"); } $z->setPassword(getenv("BACKUP_ARCHIVE_PASSWORD")); if (!$z->extractTo("/tmp/restore")) { throw new RuntimeException("Cannot decrypt archive"); } $z->close();' -
Import the dump and the files. Replace
DUMP.sqlwith the file name in/tmp/restore/db-dumps:shell dc exec -T app cat /tmp/restore/db-dumps/DUMP.sql | dc exec -T postgres sh -c 'psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"'dc exec app cp -a /tmp/restore/storage/app/. /app/storage/app/dc exec app rm -rf /tmp/restore /tmp/restore.zip -
Migrate, leave maintenance mode and start the workers:
shell dc exec app php artisan migrate --force --no-interactiondc exec app php artisan updc up -d horizon dispatcher scheduler
A failed backup, or no successful backup for 26 hours, shows in System
health and is mailed to Owners and opted-in Admins. A stopped server cannot
report itself; use INSTANCE_HEARTBEAT_URL for an independent alert, see
configuration.