Zum Inhalt springen
HitKeep
Sprache wählen
Farbschema wählen
GitHub
Kostenlos in Cloud starten

HitKeep Backup and Restore Guide

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

HitKeep keeps its operational story simple, but every 2.13 installation has an explicit storage boundary:

  • HITKEEP_DB_PATH is the shared DuckDB control-plane database
  • every tenant, including the default tenant, stores analytics in its own DuckDB file under one data-path

That means your backup strategy must follow the real storage boundary, not an older “copy one hitkeep.db file” assumption.

If you only use the default tenant, your live data is:

  • the control-plane database at HITKEEP_DB_PATH (commonly {data-path}/hitkeep.db)
  • the default tenant analytics database at {data-path}/tenants/{default_team_id}/hitkeep.db
  • your archive directory if retention archiving is enabled

Once you use non-default teams, the live data footprint becomes:

  • the control-plane database at HITKEEP_DB_PATH
  • one analytics database per tenant at {data-path}/tenants/{team_id}/hitkeep.db, including the default tenant
  • your archive directory if retention archiving is enabled

That is why the safe rule is:

Back up the whole data-path tree, not only hitkeep.db, even when you use only the default tenant.

Include the control database and archives separately if their configured paths are outside that tree.

HitKeep uses DuckDB EXPORT DATABASE with Parquet output for the shared control database and each tenant analytics catalog.

Terminal window
export HITKEEP_DATA_PATH=/var/lib/hitkeep/data
export HITKEEP_BACKUP_PATH=/var/lib/hitkeep/backups
export HITKEEP_BACKUP_INTERVAL=60
export HITKEEP_BACKUP_RETENTION=24
./hitkeep

Built-in backups include:

  • the shared control export under shared/{timestamp}/
  • each tenant snapshot, including the default tenant, under tenants/{team_id}/{timestamp}/

Use this when you want consistent application-level snapshots without relying on filesystem-level tooling.

HitKeep runs a required DuckDB checkpoint before each database export. A failed checkpoint fails that export.

A tenant export failure marks the run as failed even if other exports completed. Snapshots are written per database, without a cycle-wide completion marker. Check the backup status and verify that the selected timestamp contains the shared export and every expected tenant export before restoring. Incomplete local exports are removed when their export fails; interrupted runs or S3 failures can leave partial output. Use your object-storage lifecycle policy for S3 retention.

Instance operators can inspect the configured backup path, interval, retention, next backup, last backup, and recent failures from Administration → System Status → Operations.

Restore is an offline operation:

Terminal window
./hitkeep recover restore-backup \
-from /var/lib/hitkeep/backups \
-snapshot 2026-03-08T120000Z \
-db /var/lib/hitkeep/data/hitkeep.db \
-data-path /var/lib/hitkeep/data \
-yes

For S3-backed snapshots:

Terminal window
./hitkeep recover restore-backup \
-from s3://my-bucket/hitkeep/backups \
-snapshot 2026-03-08T120000Z \
-yes

The restore flow imports each database separately:

  1. The shared export is imported into a temporary DuckDB file, checkpointed, and closed.
  2. The existing target database and WAL are moved aside as .pre-restore.{timestamp} safety copies before the restored file is activated.
  3. The same procedure restores each discovered tenant export. A restored file must not depend on a leftover .wal.
  4. Files are activated individually, not as one atomic replacement of the whole instance. If any catalog fails, keep HitKeep stopped, correct the backup set, and rerun restore before startup.

Local restore discovers tenant directories with the selected timestamp; missing tenant exports are not proof that those teams had no data. Compare the backup set with your expected teams. S3 restore discovers the teams from the restored control database and requires an explicit -snapshot timestamp.

That means hitkeep recover restore-backup itself should not leave your restored database dependent on replaying a leftover WAL.

The .pre-restore.{timestamp} database and WAL safety copies are retained after a successful restore. Validate the restored instance first, then remove those copies according to your storage and data-retention policy; HitKeep does not rotate them automatically.

Automatic-recovery bundles under HITKEEP_DB_RECOVERY_PATH are different from backup snapshots. They preserve the exact pre-repair database and WAL for rollback or forensic work, are retained locally, and are not rotated by the backup retention setting.

Built-in backups are the easiest supported option, but external tooling is still valid.

Stop HitKeep before copying live DuckDB files, or use storage-level snapshots that quiesce the volume consistently. Do not copy an active database and WAL as unrelated files.

Terminal window
# HitKeep is stopped for this copy.
# Copy the full live data tree
rsync -az /var/lib/hitkeep/data/ backup-host:/backups/hitkeep/data/
# Copy retention archives if you use them
rsync -az /var/lib/hitkeep/archive/ backup-host:/backups/hitkeep/archive/

Or with object storage:

Terminal window
# HitKeep is stopped for this copy.
rclone sync /var/lib/hitkeep/data/ remote:my-bucket/hitkeep/data/
rclone sync /var/lib/hitkeep/archive/ remote:my-bucket/hitkeep/archive/

For every 2.13 installation, do not back up only:

Terminal window
cp /var/lib/hitkeep/data/hitkeep.db /backups/

That copies only the shared control plane and misses tenant-local analytics databases.

Production startup migrates default-tenant analytics out of the shared hitkeep.db into its tenant database when needed. The control database remains DuckDB. A physical storage format that an older engine can read is not a supported application or schema downgrade path. To return to an older release, retain the complete pre-upgrade control-and-tenant backup and the matching configuration; test that restore separately before relying on it.

New DuckDB database files and compaction outputs retain a pre-2.0 storage format. Existing files already using DuckDB 2.0’s storage format are not automatically converted. Engine-level file compatibility does not guarantee that an older HitKeep release supports the current application data or database schemas; keep a complete pre-upgrade backup.

After recover restore-backup finishes:

  1. Start HitKeep normally.
  2. Confirm login works.
  3. Open the dashboard for a site in the default tenant.
  4. Open at least one site from a non-default team if you use teams.
  5. Check that goals, funnels, ecommerce, and team-specific analytics still render.

The next normal startup may create a new, valid DuckDB .wal during runtime. That is expected. The thing to avoid is a restore that only works if an old or partial WAL is replayed.

If the default tenant’s analytics database at {data-path}/tenants/{default_tenant_id}/hitkeep.db is lost and no backup exists — for example because the data path was not on persistent storage — HitKeep refuses to start and names the missing file. Two offline commands get you running again. Stop HitKeep before using either one.

Rebuild the missing database as an empty, schema-migrated file:

Terminal window
./hitkeep recover rebuild-default-tenant

The command requires explicit confirmation because analytics history is not restored. It refuses to overwrite a database that still opens, and it sets an unreadable leftover file aside instead of deleting it.

If retention archiving was active, your aged-out analytics still exist as Parquet exports under the archive path. Import them back after the rebuild:

Terminal window
./hitkeep recover import-archives

The import is idempotent: rows that already exist are kept once, and rows that reference a deleted site, goal, or funnel are skipped rather than imported inconsistently. Data newer than your last archive run cannot be recovered this way — only a real backup holds it.

Both commands read HITKEEP_DB_PATH, HITKEEP_DATA_PATH, and HITKEEP_ARCHIVE_PATH from the environment and accept explicit -db, -data-path, and -archive-path flags. When started as hitkeep --config FILE recover …, they also read the selected configuration file, with the same precedence as the server.