Backups and restore
Backups are taken on demand. Scheduled backups are coming soon.
Create a backup
Section titled “Create a backup”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 |
Restore a backup
Section titled “Restore a backup”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).
Restore into a new database
Section titled “Restore into a new database”PostgreSQL only, with the API. Create a database with restore_from naming a finished backup of another of your databases in the same region:
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.
Upgrade PostgreSQL to a newer version
Section titled “Upgrade PostgreSQL to a newer version”A database keeps the PostgreSQL version it was created with: there are no in-place upgrades. To move to a newer version:
- Take a backup of the current database and wait until it’s done.
- Create a new database on the newer version from that backup (above), with
"version": "17"for example. - Check your app against the new database, then switch its connection string over and allow your addresses on the new database’s Firewall tab.
- 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.
Keep and delete backups
Section titled “Keep and delete backups”Backups are kept until you delete them. Deleting the database deletes all its backups too.
Backups can’t be downloaded yet. For your own copy, use your engine’s tools, for example:
pg_dump "postgresql://USER:PASSWORD@HOST:PORT/DBNAME?sslmode=require" > backup.sqlWith the API
Section titled “With the API”# 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 backupscurl "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"