Oblive Docs

Daily S3 sync

Every night from 00:15 UTC, collect every enabled integration, then take one full snapshot of the installation to S3.

One host timer and one backend command produce one thing every night: a full snapshot of the installation as it was that night. It holds every database, file store, agent workspace, the configuration and the exact images, and it is the single source for both uses of the data:

  • Replay restores it into an isolated copy.
  • Research exports a readable copy of one business from it (see readable export).

The snapshot is backup.py’s full backup; the two names mean the same thing.

What runs

From 00:15 UTC (05:45 IST), scripts/daily_sync.py:

  1. Collects: runs daily-sync.command.ts inside the running backend. It collects every integration whose capture policy is enabled, each in its own lane, up to eight at once (the in-backend scheduler runs two), so no integration waits behind another’s pages, until each integration’s job for the day finishes or 01:45 passes (90 minutes). It stops itself 15 minutes after that whatever it is doing; capture jobs resume on a rerun. A MongoDB database with a mongodb_database resource is copied in full every night this way, read directly from a secondary (about 30 minutes and 560 MB compressed for SocialKit’s 4.6 GB); see history capture.
  2. Takes the full snapshot with backup.py. It pauses new agent work and waits up to 30 minutes for running work to finish; the site stays usable. It then puts the backend in maintenance and waits up to 30 more minutes for the backend’s own background work. During this wait the site is read-only: stored chats and tasks can be viewed, but sending a message or making a change returns “paused for backup”. Then it stops the services to copy them: the copy is capped at 10 minutes and the whole stop at 15. The site is unavailable during the stop, which must begin before 03:30.
  3. Uploads daily/<organization>/<day>/manifest.json, naming the snapshot.

<day> is the UTC day the snapshot closes: collection from 00:15 UTC on 17 November records the state at the end of 16 November, so that night’s files are labelled 2026-11-16. Collection and the snapshot finish after midnight, so a night also holds up to about two hours of the next day. The stop usually comes around 01:45–02:45 UTC (07:15–08:15 IST, 20:45–21:45 US Eastern).

On 17 November 2026 on the live host, the snapshot was 5.2 GB, the site was read-only for under two minutes and stopped for 3 minutes 35 seconds. The final wait is 30 minutes rather than backup.py’s default of 30 seconds, because the first attempt that day was refused when a background cycle was still running after 30 seconds.

The timer fires every 15 minutes. The first tick after 00:15 starts the day. A failed run retries on the next tick until 04:30. .runtime/daily-sync/<organization>/<day>.json records the collection summary and then the snapshot, so a retry never takes a second snapshot. A finished day is not run again, even if it was incomplete.

  • Until 01:45 every retry resumes collection. After that a retry asks the backend only for each integration’s state (within five minutes), and once the summary is saved it skips the backend.
  • A failed snapshot writes no manifest. The next tick retries a new capture until 03:30. A capture that was copied but not uploaded is uploaded by the next tick at any time until 04:30, since that needs no stop.
  • A staged capture records the organization and day it is for. A retry uploads only that day’s own capture; one left by another night or by backup.py is uploaded as its own snapshot first, and the day then takes a new one.
  • Every tick, inside the window or not, first undoes what an interrupted snapshot left behind: stopped services, read-only maintenance and paused agent work. This needs no S3 access, so an expired AWS session cannot keep the site offline.

S3 layout

s3://<backup bucket>/snapshots/<stamp>/…
s3://<backup bucket>/daily/<organization>/<YYYY-MM-DD>/manifest.json

manifest.json is written last, so a day without it has no snapshot yet. It records the day, the backend release image, start and finish times, the snapshot (snapshot.stamp, size, pauseSeconds) and each integration’s name, provider, collection state, gaps and number of archives. complete is false when any integration is partial or missing.

The bucket is the versioned, private backup bucket configured by backup.py init. How long snapshots are kept is the bucket’s lifecycle policy.

When historyArchiveS3 is set, collected history (integration captures and native database backups) is stored in that separate bucket and the snapshot only refers to it. A snapshot is complete only while that bucket still holds every archive the snapshot refers to, so keep history at least as long as snapshots. Tying the two together is not built yet.

Refreshed archive credentials

historyArchiveS3 can use either its existing accessKeyId / secretAccessKey pair (with optional sessionToken) or a host-owned credentialsFile ending in /credentials.json. Do not combine the modes. The file contains AWS STS AccessKeyId, SecretAccessKey, SessionToken and Expiration. The host must refresh it atomically before expiry.

The portable stack mounts its directory read-only into the backend at /run/oblive/history; agents receive neither the archive credentials nor the mount. Reads and writes reload changed credentials without a restart and fail closed on expiry, malformed JSON or missing files. Existing archive keys retain their bucket/region and encrypted bytes; this changes authentication only. It does not extend archive retention or make older snapshots independently recoverable.

Deploblive JSON configuration can supply nonsecret historyArchive with bucket, region and organizationId for an existing archive. It creates a separate role restricted to that organization’s organizations/<id>/history/ prefix and a host-owned refresh timer. The role does not grant deletion of object versions or access to other organizations. The original bucket must permit the role (and any customer-managed encryption key needs its own explicit access); borrowed bucket policies are never rewritten. A coordinated application release advertising rotating-history-credentials-v1 is required. Older releases remain compatible when this setting is absent.

Restore a day

Restore the snapshot named in that day’s manifest.json into a new directory:

python3 scripts/backup.py restore <snapshot.stamp> --target /path/to/day --instance day-2026-11-16

The copy starts in recovery mode on an isolated network: no provider calls, agents or background jobs, so it is safe to inspect. backup.py activate turns agents and background work back on with the restored credentials; it is meant for replacing the original installation. See backups.

Replays trials run inside an installation from its own recorded history. A restored copy holds all history up to that night, but running trials on it without activating it is not built yet.

Readable export

The readable business export is made from a snapshot, not from the live installation, with history_export.py --format business --snapshot <snapshot.stamp>. It restores the snapshot’s databases into throwaway containers and writes the same integrations/ and harness/ folders. See export a frozen backup for its options. Running it automatically after each night’s snapshot is not built yet.

Set up

  1. Configure the backup bucket with python3 scripts/backup.py init if it is not configured yet.
  2. Make sure the host has free disk space for twice the uncompressed volumes and images plus 1 GiB. The snapshot fails its preflight check otherwise.
  3. Set historyDailyPreservation: true in local-stack.json (HISTORY_DAILY_PRESERVATION=true). This turns off the backend’s own scheduled collection so integrations are not collected twice. Tool call recording, Insights copies, expiry and history removal keep running.
  4. Enable the capture policies that should be included.
  5. Run one day by hand, then install the timer:
python3 scripts/daily_sync.py run --root <install root> --organization <id> --day 2026-11-16
python3 scripts/daily_sync.py install --root <install root> --organization <id>
python3 scripts/daily_sync.py remove --root <install root> --organization <id>

Do not also install backup.py’s own nightly timer: the sync already takes the nightly snapshot, and the two share one instance lock. Each tick prints one JSON line to .runtime/backup/schedule.log. A failure line names the step that failed and never includes command output.

Not included

  • An alert when a night has no snapshot. Check for that day’s manifest.json.
  • A restore test of each night’s snapshot. Run backup.py verify <stamp> or a restore by hand.
  • Running Replays trials on a restored snapshot without activating it.
  • Running the readable export automatically after each snapshot.
  • Converting a night’s MongoDB copy (gzip BSON, mongodump’s collection format) to readable records in the export, and loading it into an isolated MongoDB for a trial. Both are next.

UTC rollout and compatibility

New manifests declare timezone: "UTC". Collection windows are unchanged: SocialKit logs use completed UTC days, PostHog events use a rolling 24 hours, and provider daily aggregates retain their reporting timezone. --day is a label, not a historical backfill.

Set any existing backup.json timezone to UTC; changing the default alone does not update saved configuration. The host OS timezone does not need to change.