How to Back Up PostgreSQL and MongoDB with Encryption and Offsite S3 (3-2-1 Rule) Using a Free Rust Tool
Short answer: install ChronoBase (free, MIT-licensed, Windows/Linux/macOS), add your databases under Connections, turn on Encryption at rest and Offsite S3 Upload in Setup, add a cron schedule, configure failure alerts a
Short answer: install ChronoBase (free, MIT-licensed, Windows/Linux/macOS), add your databases under Connections, turn on Encryption at rest and Offsite S3 Upload in Setup, add a cron schedule, configure failure alerts and a heartbeat URL, and run chronobase drill monthly to prove restores work. The sections below walk through each step and explain the reasoning.
What you will build
A backup pipeline that satisfies the 3-2-1 rule (3 copies of your data, on 2 different media, with 1 offsite) for PostgreSQL and MongoDB, with:
- scheduled dumps with retention
- encryption at rest (
XChaCha20-Poly1305) with the key in your OS keyring - offsite copies in S3-compatible storage with Object Lock
- failure alerts and a dead-man's-switch heartbeat
- a verified restore path and a monthly restore drill
No hosted service, no account, no telemetry. Everything runs on your machines.
How the 3-2-1 rule maps to ChronoBase
| 3-2-1 requirement | ChronoBase feature |
|---|---|
| Copy 1: local backup | Scheduled dumps into <data_dir>/backups/<Group>/<Date>/
|
| Copy 2 and 3: offsite | Offsite S3 Upload (AWS S3, Cloudflare R2, Backblaze B2, MinIO) with optional Object Lock |
| Protection against theft and ransomware | Encryption at rest (CBENC1) and Object Lock so leaked keys cannot delete locked objects |
| Detect silent failure | Slack, Discord, Telegram, or webhook alerts plus a heartbeat URL |
| Prove recoverability |
chronobase drill and chronobase scrub
|
Prerequisites
-
ChronoBase from the Releases page. Installers: Windows (
.exe,.msi, portable.zip), Linux (.tar.gz,.deb), macOS (.dmgfor Apple Silicon and Intel). Each release includesSHA256SUMS.txt. - The official database CLI tools. ChronoBase calls them directly and does not bundle them:
| Platform | PostgreSQL (pg_dump, psql) |
MongoDB (mongodump, mongorestore, mongosh) |
|---|---|---|
| Windows | Install the Command Line Tools from postgresql.org | Install the MongoDB Database Tools MSI |
| macOS | brew install libpq && brew link --force libpq |
brew tap mongodb/brew && brew install mongodb-database-tools |
| Debian / Ubuntu | sudo apt install -y postgresql-client |
sudo apt install -y mongo-tools |
- Unsigned binaries trigger OS prompts on first launch: on Windows choose More info β Run anyway; on macOS right-click β Open, or run
xattr -cr /Applications/ChronoBase.app.
Run chronobase doctor to confirm the tools, free disk space, file permissions, and key vault are healthy.
Step 1: Create a read-only backup user
Do not back up with an admin password. In the connection dialog, click Least-privilege SQL to copy a ready-made read-only user script. On PostgreSQL 14 or later, a typical equivalent looks like this (run as an administrator, adjust names):
CREATE ROLE backup_user LOGIN PASSWORD 'use-a-long-random-password';
GRANT CONNECT ON DATABASE app TO backup_user;
GRANT pg_read_all_data TO backup_user;
A restricted user limits the damage if the connection string is ever exposed.
Step 2: Add your databases
- Open Connections β + Add connection.
- Choose the engine, enter a friendly name and a group (for example
Production,Staging,Local), and paste the connection string.- PostgreSQL:
postgresql://username:password@host:5432/database_name - MongoDB:
mongodb://username:password@host:27017/database_nameormongodb+srv://...for Atlas
- PostgreSQL:
- Click Test connection before saving. It checks reachability, warns if you are connecting through a pooler such as PgBouncer or Supavisor, and supports custom TLS CA certificates.
- For PostgreSQL choose a format:
| Format | When to use |
|---|---|
| Plain SQL | Human-readable; simplest restore with psql
|
Custom (-Fc) |
Compressed, supports selective restore, verifiable with pg_restore --list
|
Directory (-Fd) |
Parallel dump and restore for larger databases |
Optionally enable Include cluster globals (pg_dumpall --globals-only) to capture roles and tablespaces.
- Under Advanced you can route through an SSH jump host or point backups at a read replica to keep load off the primary, while restores still use the primary URL.
If you already have a .env file, chronobase config import-env .env discovers database URLs automatically. Connection URLs, passwords, and endpoints are masked in the interface, so screenshots are safe to share.
Step 3: Turn on encryption at rest
- Open Setup β Security, Encryption & Offsite S3.
- Enable Encryption (
XChaCha20-Poly1305) and Gzip compression. -
Save the one-time Recovery Key (it starts with
CBREC-) in a password manager. If you want two-person custody, generate a 2-of-2 split recovery key so neither person holds the whole secret. - Keep Minimum free disk space at 256 MB or more so a full disk cannot corrupt a backup run.
The master key is stored in Windows Credential Manager, macOS Keychain, or Linux secret-tool. Encrypted files use the documented CBENC1 format, which means you can decrypt them without the GUI (see Step 10).
Step 4: Add the offsite copy
- In the same Setup section, enable Offsite S3 Upload.
- Enter the endpoint, bucket, region, and credentials for AWS S3, Cloudflare R2, Backblaze B2, or MinIO.
- Set Object Lock retention days if your provider and bucket support it. With Object Lock, even a stolen access key cannot delete locked backups, which is the control that matters against ransomware. Check your provider's documentation for how to enable Object Lock on the bucket.
Because backups are encrypted before they leave the machine, the bucket only ever holds ciphertext.
Step 5: Schedule backups and set retention
- Go to Schedules β + New schedule.
- Choose a target group (or
All) and a preset or a 5-field cron expression. Example for 02:00 every day:0 2 * * *. - Click Run on the schedule once to test it immediately. If your computer is asleep during a scheduled time, missed runs catch up on wake.
- Under Automatic Retention, set Keep last (count), Max age (days), and Failed age (days), then click Preview to see what would be deleted before you Save policy. ChronoBase always preserves the newest healthy backup per database.
- For calendar-based retention (hourly, daily, weekly, monthly, yearly buckets, also called grandfather-father-son), configure
retention.gfsinchronobase-data.jsonor throughconfig export/config import. - Pin any snapshot you must never lose (an audit, a tax year, a pre-release state). A pinned backup is exempt from automatic retention and accidental deletion.
To keep schedules running when the window is closed, enable Run in background (system tray) and Run on OS startup in the sidebar, or run the headless daemon:
chronobase --headless
For servers, use a systemd user unit:
[Unit]
Description=ChronoBase Backup Scheduler
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/chronobase --headless
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
systemctl --user enable --now chronobase
Step 6: Get alerts when something fails
In Setup, configure a Slack, Discord, Telegram, or custom webhook destination for failure alerts, and set Quiet Hours so you are only interrupted when it matters.
Add a Heartbeat URL (a dead-man's-switch service such as hc-ping.com or Cronitor). Alerts tell you when a backup fails; a heartbeat tells you when the backup machine stopped running at all.
Step 7: Back up a private server without opening database ports
If your databases run on a VPS, use the pull agent instead of exposing PostgreSQL (5432) or MongoDB (27017):
# On the VPS: generate a 256-bit pairing key and a 0600 config
chronobase agent-init --bind 0.0.0.0:9443
# Start the agent. Restrict by IP, or bind 127.0.0.1 behind SSH/Tailscale.
chronobase --agent --bind 0.0.0.0:9443 --allow-ip <YOUR_HOME_OR_TAILSCALE_IP>
In the desktop app: VPS & Migrate β + Add VPS peer, enter the endpoint (host:9443), engine, the VPS-local database URL, and the pairing key. Verify that the Key SHA-256 fingerprint matches the server's, then click Pull (or script chronobase pull <vps-name>).
The transfer uses a mutual HMAC-SHA256 handshake, ChaCha20-Poly1305 encryption, and SHA-256 verification. The temporary dump on the VPS is deleted after the client confirms the checksum.
Step 8: Verify that backups actually restore
An untested backup is an assumption. Build verification into the routine:
# Re-check SHA-256 of every stored snapshot against its manifest (detects bit rot)
chronobase scrub
# Restore a snapshot into a scratch database, run checks, and measure recovery time
chronobase drill <backup_id> <scratch_db_url>
# Confirm the tamper-evident audit log chain is intact
chronobase audit-verify --json
Schedule this monthly. ChronoBase also flags anomalies: a backup that shrinks by more than 50% pauses retention pruning so a mass delete cannot silently rotate out your good history.
Step 9: Restore safely
- Open Backups, find the snapshot (grouped by project and date), and click Restore.
- Choose Same DB or Different DB. For Same DB, ChronoBase takes an automatic safety backup first and requires you to type the database name to confirm.
- To restore only part of a database, list PostgreSQL tables (
--table) or MongoDB namespaces (--nsInclude), comma-separated, in the Restore dialog. - For a quick copy between environments, use Migrate DB β DB (for example, production to a local development database), which checks engine compatibility and PostgreSQL major-version parity.
If you need to share staging data with other developers, ChronoBase includes deterministic masking helpers for emails, phones, and sensitive IDs.
Step 10: Offline disaster recovery (no GUI needed)
If your laptop is gone, you can recover from the bucket and your Recovery Key on any clean machine.
- Install ChronoBase (or any existing binary) on the new machine.
- Download
<data_dir>/backups/from your S3 bucket or offline drive. - Decrypt:
chronobase decrypt ./backups/Prod/2026-12-03/app_20261203_020001.dump.cbenc ./app.dump --recovery-key CBREC-...
- Restore into a fresh PostgreSQL instance:
pg_restore --clean --if-exists --no-owner -d postgresql://user:pass@localhost:5432/app ./app.dump
The CBENC1 format is publicly specified, so the files remain decryptable independent of the application.
Incident playbook: "I got hacked"
- Click Danger Zone β Activate Freeze, or run
chronobase freeze. This locks automatic retention and all manual deletions and takes an immediate snapshot of every configured database, pinned as forensic evidence. - Run
chronobase audit-verify --jsonto confirm the audit log chain is intact. - Run
chronobase scrubto verify SHA-256 integrity of all stored snapshots. - Export evidence for responders:
chronobase compliance --format json > incident-compliance.json.
ChronoBase vs. a cron job with pg_dump
| Concern | Cron + shell script | ChronoBase |
|---|---|---|
| Scheduling | Yes (cron) | Yes, with missed-run catch-up and a Run button |
| Password handling | Easy to leak into argv or shell history |
Passed through environment variables or 0600 temp files, never argv; masked in the UI |
| Encryption at rest | Manual (gpg/age) |
Built in (CBENC1), key in OS keyring |
| Integrity verification | Manual | SHA-256 manifest per file, chronobase scrub
|
| Offsite upload | Manual (aws s3 cp, rclone) |
Built in, with Object Lock option |
| Failure alerts | Manual | Slack, Discord, Telegram, webhooks, heartbeat |
| Restore testing | Rarely done |
chronobase drill measures recovery time |
| Visual history and restore | None | Desktop UI with grouped history, one-click restore |
A well-maintained script can do all of this. ChronoBase packages the pieces so you do not have to write and maintain them.
When ChronoBase is not the right tool
- You need point-in-time recovery to a specific second. ChronoBase takes logical dump snapshots, so your recovery point is the schedule interval. Use WAL-based continuous archiving tooling for that requirement.
-
You need a multi-tenant, role-based platform for a large team. ChronoBase includes a headless web console, token-protected REST API, and Prometheus
/metrics, but it is designed for individuals and small teams. -
You need code-signed binaries today. Release binaries are unsigned; verify them against
SHA256SUMS.txt.
Frequently Asked Questions
What is the best free tool to back up PostgreSQL and MongoDB from a desktop?
ChronoBase is an open-source (MIT) backup manager with a native Rust + Slint desktop UI, a headless scheduler, and a CLI. It wraps pg_dump and mongodump and adds scheduling, encryption, offsite upload, alerts, and restore drills.
How do I encrypt PostgreSQL backups?
In ChronoBase, enable Encryption at rest in Setup. Dumps are encrypted with XChaCha20-Poly1305 in the CBENC1 format, the master key is stored in your OS keyring, and a Recovery Key lets you decrypt on any machine with chronobase decrypt.
How do I back up a database on a VPS without exposing port 5432 or 27017?
Run chronobase --agent on the VPS and pull from your desktop. The connection is authenticated with a mutual HMAC-SHA256 handshake and encrypted with ChaCha20-Poly1305, so the database port never needs to be public.
How do I protect backups from ransomware?
Upload encrypted backups to an S3-compatible bucket with Object Lock, so even compromised credentials cannot delete locked objects, and pin critical snapshots as a legal hold.
How do I know my backups actually work?
Run chronobase drill <backup_id> <scratch_db_url>, which restores into a scratch database, runs checks, and reports recovery time. Pair it with chronobase scrub to detect silent file corruption.
Does ChronoBase send my data or credentials anywhere?
No. There is no telemetry and no ChronoBase cloud service. Offsite upload goes only to a bucket you configure.
Which operating systems are supported?
Windows 10/11 x64, Linux x86_64 (X11 and Wayland), and macOS on Apple Silicon and Intel.
Get started
- Repository: github.com/Subham-Maity/chronobase
- Downloads: github.com/Subham-Maity/chronobase/releases
- In the repository:
GUIDE.md(annotated walkthrough),RUNBOOKS.md(3-2-1 setup and playbooks),SPEC.md(file formats),SECURITY.md(threat model)
ChronoBase is created and maintained by Subham Maity.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.






