Skip to content

Scheduled Backups

Requires the Enterprise Edition.

What it does

Full mongodump backups of the Syncer database on a schedule, with rotation. Each backup configuration writes to one of two destinations:

  • Local path: a directory on the Syncer host. This also covers network storage: mount a CIFS or NFS share at the OS level and point the path at the mount point.
  • S3-compatible object storage: AWS S3, Google Cloud Storage (S3 interop), Azure Blob (S3 endpoint), MinIO, Ceph Object Gateway, Backblaze B2, Wasabi, DigitalOcean Spaces.

Pipeline:

mongodump --archive  →  gzip  →  [gpg --encrypt]  →  local file or S3 object

Everything streams, so a 10 GB dump never needs 10 GB of scratch space. Retention is enforced after each successful run.

Requirements

  • mongodump on the PATH of the Syncer OS user (package mongodb-database-tools), mongorestore for restores.
  • gpg if you enable encryption.
  • For S3 only: pip install 'cmdbsyncer-enterprise[backup]' (pulls in boto3).

Backup to a local path

Under Settings → Backups → Configs → Create:

Field Example
name nightly-local
destination_type local
local_path /var/backups/cmdbsyncer
compression gzip
encryption none or gpg
retention_days 14

local_path must be an absolute path and writable by the Syncer process. Each run writes one file:

<local_path>/<name>/<timestamp>.gz        e.g. /var/backups/cmdbsyncer/nightly-local/20261118T030000Z.gz
<local_path>/<name>/<timestamp>.gz.gpg    with encryption = gpg
<local_path>/<name>/<timestamp>.bson      with compression = none

The file is a mongodump archive of the whole database (not a tar file). It is first written as <timestamp>.gz.tmp and renamed when the dump is complete, so an interrupted run never leaves a file that looks like a valid backup.

When the Syncer runs in Docker, local_path is a path inside the container. Mount a host directory or share there as a volume, otherwise the backups are lost with the container.

Backup to S3

  1. Create a Syncer Account of type S3-compatible object storage:

    Field Example
    name s3-backups
    address blank for AWS, e.g. https://s3.eu-central-003.backblazeb2.com for B2
    username access key id, blank to use the default AWS credential chain or IAM role
    password secret access key
    custom_fields region: eu-central-1
  2. Under Settings → Backups → Configs → Create:

    Field Example
    name prod-daily
    destination_type s3
    bucket cmdbsyncer-backups
    prefix prod/
    account s3-backups
    s3_sse AES256 (optional server-side encryption)
    compression gzip
    encryption gpg
    gpg_recipient ops-backups@example.com
    retention_days 30

Objects land under <prefix>/<name>/<timestamp>.gz[.gpg] in the bucket.

Scheduling

The schedule is part of the backup configuration (section Schedule):

Field Meaning
schedule_enabled Run on the schedule. Disable to pause without deleting.
interval How often, e.g. daily (first cron tick inside the window).
custom_interval_in_minutes Optional, overrides interval.
timerange_from / to Time of day window, default 2 to 6.

On save, the Syncer creates a protected CronGroup Backup: <name> with the task enterprise-backup_run:<name> and keeps it in sync with these fields. You can pause it in the Cron view, but not delete it; deleting the backup configuration removes it. The backup then runs like any other cron group: retries, continue_on_error and cron stats apply.

You can also add the task enterprise-backup_run:<name> to one of your own CronGroups, for example to run the backup right after an import.

To test a configuration, select it in the list and use the bulk action Run backup now. The result shows under Backups → History.

Encryption

  • none: relies on the protection of the target (file system permissions, S3 at-rest encryption).
  • gpg: the archive is encrypted for a recipient public key in the Syncer OS user's keyring. Only holders of the private key can restore.

Manage the keyring with gpg --import as the Syncer user. In containers, mount ~/.gnupg as a secret or volume.

Retention

After each successful run, backups older than retention_days are deleted. 0 keeps everything.

  • Local: every file in <local_path>/<name>/ whose modification time is older than the limit. Keep nothing else in that directory.
  • S3: every object under <prefix>/<name>/ older than the limit.

Restore

Restore reverses the pipeline with the MongoDB tools:

backup file  →  [gpg --decrypt]  →  gunzip  →  mongorestore --archive --drop

From a local backup:

gunzip -c /var/backups/cmdbsyncer/nightly-local/20261118T030000Z.gz \
    | mongorestore --uri "mongodb://localhost:27017" --archive --drop

Encrypted:

gpg --decrypt /var/backups/cmdbsyncer/nightly-local/20261118T030000Z.gz.gpg \
    | gunzip -c \
    | mongorestore --uri "mongodb://localhost:27017" --archive --drop

From S3, download the object first (e.g. aws s3 cp) and run the same commands on the file.

Warning

mongorestore --drop wipes each collection before restoring it. Restore into a scratch database first, verify it, then cut over. To restore under a different database name, add --nsFrom 'cmdbsyncer.*' --nsTo 'cmdbsyncer_restore.*'.

Observability

  • Audit Log: backup.succeeded and backup.failed with size, duration and target path or object key.
  • Notifications: the same events go to the notification dispatcher, so you can alert on failure or send a digest on success.
  • Prometheus Metrics: the backup runs as a cron group, so the CronGroup metrics cover it. Alert on the age of cmdbsyncer_cron_group_last_success_timestamp_seconds{group="Backup: prod-daily"}.
  • History view: Backups → History lists every run (running, success, failure) with size, duration, target and error message.

Multiple destinations

Create several backup configurations, for example daily to a local path and weekly to S3. Each one has its own schedule and retention.

Restore into a clean install

  1. Install CMDBsyncer and the Enterprise package as usual.
  2. Copy local_config.py and license.jwt from the source install (or issue a fresh license).
  3. Restore the latest archive as shown above.
  4. Restart the app and the cron runner.

The restored database contains everything: accounts, rules, users, cron schedules, audit history and secret bindings.