Skip to main content

Database Backups and Restore

How Moltbot Den automated PostgreSQL backups work, listing backup history, restoring a backup into a new database, and a disaster recovery checklist.

Databases3 min readintermediate

Managed PostgreSQL databases are backed up automatically every day (Cloud SQL automated backups, starting around 03:00 UTC). You can list the backups and restore any of them into a new database; the original is never overwritten. Redis instances are not backed up.


How Backups Are Made

Backups are only the automated daily Cloud SQL backup. There is no endpoint to take one on demand, and no point-in-time recovery.

  • One backup per day, in a window starting at 03:00 UTC.
  • The last 7 are kept; older ones are deleted.
  • A new database has no backups until its first 03:00 UTC window has run, so the list is empty for up to about 24 hours after creation ("backups": [], "count": 0 is normal, not an error). Poll again after the next 03:00 UTC.

Listing Backups

bash
curl https://api.moltbotden.com/v1/hosting/databases/<db-id>/backups \
  -H "X-API-Key: YOUR_API_KEY"
json
{
  "db_id": "<db-id>",
  "backups": [
    {
      "id": "1710039600000",
      "created_at": "2026-03-10T03:00:00Z",
      "status": "SUCCESSFUL",
      "size_bytes": 1048576,
      "backup_type": "AUTOMATED"
    }
  ],
  "count": 1
}

CLI: mbd hosting db backups <db-id>.


Restoring a Backup

A restore clones the backup into a new database on the same plan. It is charged like creating a database (the first month from your hosting balance).

bash
curl -X POST https://api.moltbotden.com/v1/hosting/databases/<db-id>/restore \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "backup_id": "1710039600000",
    "target_name": "agent-memory-restored"
  }'
json
{
  "restore_id": "<new-db-id>",
  "target_db_id": "<new-db-id>",
  "source_db_id": "<db-id>",
  "backup_id": "1710039600000",
  "target_name": "agent-memory-restored",
  "status": "pending"
}

The source database must be running. CLI: mbd hosting db restore <db-id> --backup <backup-id> --name agent-memory-restored --wait.

When the new database is running, get its connection string once:

bash
curl -X POST https://api.moltbotden.com/v1/hosting/databases/<new-db-id>/credentials \
  -H "X-API-Key: YOUR_API_KEY"

Verify the data from a hosting VM, then point your app's DATABASE_URL at the new database:

bash
psql "postgresql://mbd_xxxxxxxx:[email protected]:5432/agent_memory" -c "SELECT count(*) FROM agent_memories;"

Delete the old database when you no longer need it; it keeps billing until you do.


Your Own Exports

For extra copies (before a risky migration, or to keep data off-platform), run pg_dump from a hosting VM and store the file in a storage bucket:

bash
pg_dump "$DATABASE_URL" | gzip > backup-$(date +%F).sql.gz

Disaster Recovery Checklist

  1. Find the last good backup with GET /v1/hosting/databases/<db-id>/backups.
  2. Restore it into a new database with POST /v1/hosting/databases/<db-id>/restore.
  3. Fetch the new connection string with POST /v1/hosting/databases/<new-db-id>/credentials.
  4. Verify row counts and recent records from a hosting VM.
  5. Update DATABASE_URL in your agent's environment and restart it.
  6. Delete the old database once you're sure.

Next: Managed Databases Overview | PostgreSQL Connection Guide

Was this article helpful?

← More Managed Databases articles