Skip to content

Backups and restore

Take backups on demand, or turn on automatic backups to take one every day or every week. You can restore a backup, restore it into a new database, or download it.

In the database’s Backups tab, switch on Enable automatic backups and choose:

  • Backup Frequency: Daily or Weekly (pick the day for weekly).
  • Backup Time (UTC): the hour the backup starts.
  • Keep (backups): how many automatic backups to keep, up to 30. When a new one finishes, the oldest automatic backup beyond that number is deleted.

The tab shows Next Scheduled. Automatic backups appear in the list next to the ones you take yourself. Backups you take on demand are never deleted by the schedule.

If the database is stopped or a backup is already running at the scheduled time, that backup is skipped and the next one runs as planned. After a pause, one catch-up backup is taken, not one for every missed slot.

Automatic backups work for PostgreSQL, MySQL, MariaDB and Redis.

Open the database and click Backup in the header, or Create Backup in the Backups tab. The database must be running. The backup appears as Queued, then In progress, then shows its size when it’s done.

One backup per database runs at a time.

Engine Backup Restore
PostgreSQL Yes (SQL dump) Yes
MySQL Yes (SQL dump) Yes
MariaDB Yes (SQL dump) Yes
Redis Yes (snapshot) Not yet
RabbitMQ No No

In the Backups tab, click the restore icon on a backup and confirm. The backup is restored into the same database and overwrites its current data. You can’t restore while a backup is running.

PostgreSQL backups are taken with the pg_dump of the database’s own version, and each backup shows the version it came from (for example PostgreSQL 16).

PostgreSQL only, with the API. Create a database with restore_from naming a finished backup of another of your databases in the same region:

Terminal window
curl -X POST "https://api.dockhive.io/api/v1/databases?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"engine": "postgresql", "db_name": "app", "restore_from": {"db_id": "'$DB'", "backup_id": "BACKUP_ID"}}'
  • Without version, the new database runs the same PostgreSQL version as the backup.
  • You can pass a newer version (see below). An older version is refused.
  • The new database gets its own hostname, user and password; tables and other objects owned by the old database’s user are owned by the new user. Roles you created yourself aren’t copied, so a backup that grants privileges to them can’t be restored into a new database: create the database, add the roles, then restore with the restore icon instead.
  • If the restore fails, the new database is deleted again and the response says why. The original database and backup are untouched.

A database keeps the PostgreSQL version it was created with: there are no in-place upgrades. To move to a newer version:

  1. Take a backup of the current database and wait until it’s done.
  2. Create a new database on the newer version from that backup (above), with "version": "17" for example.
  3. Check your app against the new database, then switch its connection string over and allow your addresses on the new database’s Firewall tab.
  4. Delete the old database when you no longer need it.

Writes made to the old database after the backup aren’t copied, so stop writes (or plan a short maintenance window) before step 1.

Backups you take on demand are kept until you delete them. Automatic backups are kept up to the number you chose. Deleting the database deletes all its backups too.

In the Backups tab, click the download icon on a finished backup. Only the database’s owner, and workspace members who can see database passwords, can download backups.

Engine File
PostgreSQL Plain SQL (pg_dump), restore with psql
MySQL SQL (mysqldump), restore with mysql
MariaDB SQL (mariadb-dump), restore with mariadb
Redis RDB snapshot

For example, to load a PostgreSQL backup into another server:

Terminal window
psql "postgresql://USER:PASSWORD@HOST:PORT/DBNAME?sslmode=require" < backup.sql

Each download link works once and expires after 5 minutes. Downloads show up in the database’s activity.

Terminal window
# Start a backup (returns a backup_id)
curl -X POST "https://api.dockhive.io/api/v1/databases/$DB/backups?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY"
# List backups
curl "https://api.dockhive.io/api/v1/databases/$DB/backups?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY"
# Restore one (overwrites current data)
curl -X POST "https://api.dockhive.io/api/v1/databases/$DB/backups/BACKUP_ID/restore?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY"
# Turn on daily backups at 02:00 UTC, keep 7
curl -X PUT "https://api.dockhive.io/api/v1/databases/$DB/backups/schedule?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"frequency": "daily", "hour_utc": 2, "retention": 7}'
# Weekly on Sunday instead (weekday: 0 = Monday ... 6 = Sunday); "off" turns it off
# -d '{"frequency": "weekly", "weekday": 6, "hour_utc": 3, "retention": 4}'
# Get a one-time download link for a backup
curl -X POST "https://api.dockhive.io/api/v1/databases/$DB/backups/BACKUP_ID/download?region=$REGION" \
-H "Authorization: Bearer $DOCKHIVE_API_KEY"