Databases on a cluster
The two promises, the backup every 15 minutes, how much a failover can lose, and names that work across servers.
A managed database on a cluster comes back on another server when its server stops. It comes back from a backup, so the page is honest about what that can lose.
The two promises
Wherever Deplo describes a database's failover, it makes two promises, in these words:
- "Never two writers". A database never runs on two servers at once. The server that went silent stops its own database before another one starts it.
- "A failover restores the latest backup, and says how old it was". Whatever was written after that backup is lost, and Activity names the backup.
Place a database on a cluster
- A new one: Create database, and pick the cluster in the Server field. It needs Create databases.
- One you have: its Settings -> General -> Server -> Move. It needs Configure databases.
The cluster picks the server. Both dialogs show the two promises and what a failover can lose before you confirm.
- A database on a cluster cannot be published on a host port from the Create dialog. The option is hidden while a cluster is picked.
- To take it off the cluster, Move it to a server. Its backup schedule stays.
The failover backup
Placing a database on a cluster gives it a backup named Failover backup: every 15 minutes,
keeping the last 8. Activity says Backs up db every 15 minutes to server-b.
- A database that already has a backup schedule keeps its own, as it is, even when that schedule is switched off. PostgreSQL is the exception, see below.
- A database that came with its server (the server joined the cluster) gets it once the cluster has two servers.
Where the backup goes
Never the server the database runs on. Deplo picks, in this order:
- a bucket your team already has
- a destination on another server of the cluster
- a destination on a server outside the cluster
A destination whose last test failed is skipped. With none, Deplo creates one on another server of the cluster, or on Deplo's own server when the cluster has no other. No bucket is needed.
With no other server at all, Activity says: db has no backup: there is no other server to keep one on. Add a server to its cluster or a backup destination.
A failover can only restore a backup that another server of the cluster can read by itself: one in a bucket, or one kept on another server of the same cluster. The third choice above keeps the data safe, but a failover cannot use it.
What a failover can lose
The database's Overview has a Failover card: "Runs on cluster eu, now on server-b. Backed up to server-c." Under the two promises it says how much can be lost and how long recovery takes.
| The card says | When |
|---|---|
| "A failover can lose up to 15 minutes of writes: everything since the last backup." | The usual case. The span follows the database's own schedule, so it can read "24 hours" |
| "A failover can lose about a minute of writes: its change log is archived continuously." | PostgreSQL, once its first backup on the cluster has finished |
| "No backup is scheduled, so a failover has nothing recent to restore." | No schedule is switched on |
| "Recovery takes a few minutes." | Until a restore of this database has been measured |
| "Recovery takes about 4 minutes: the last backup is 1.2 GiB." | After one: the last backup's size and the speed of the last restore, a failover included |
To lose about a second instead, see Standby copy.
PostgreSQL loses about a minute
A PostgreSQL database on a cluster also archives its change log continuously, to the same destination as its backups. There is nothing to switch on: placing it on the cluster starts it, leaving stops it. Every other engine restores its latest backup only.
- Its Failover backup is a base backup, a copy of the database's files (the file name ends in
.base.tar.gz), not a dump. It gets this schedule even when it already has schedules of its own. Those, and a backup taken by hand, stay dumps. - A base backup restores from the Backups tab like any backup, to the moment it was taken. It
cannot be loaded with
pg_restore, and uploading it is refused: "That is a base backup of a Postgres database on a cluster, not a dump. Restore it from that database's Backups tab." - The change log is kept beside the base backup it follows, encrypted like the backups of that destination, and deleted with it.
- If the destination cannot be reached for more than 30 minutes, PostgreSQL drops what it could not hand over, so the database's disk never fills. The card goes back to the 15-minute sentence until the next base backup finishes.
- Not archived: a PostgreSQL database with a custom start command, or with an image that is
not the official
postgresone. It keeps the 15-minute promise. - A database that came onto the cluster with its server is not restarted. Activity says:
main archives its change log once it is redeployed. Until then a failover restores its latest backup.Redeploy is the button on the database's page.
When its server stops
Databases come back first, before the apps:
- The leader waits about 25 seconds, until that server has stopped the database itself. See When a server stops.
- It restores the database on another server from the newest finished backup that server can read.
- Only then does it start the apps.
It does this with Deplo itself stopped too, on a cluster of three servers or more. See How many servers. Activity, by Deplo:
Restored db on server-b from the backup of 14:15- PostgreSQL with an archived change log:
Restored main on server-b from the backup of 14:15 and its change log up to 14:27
The time is in the backup schedule's timezone. A backup of another day carries its date: from the backup of 27 Feb, 03:00.
Good to know:
- A published database (a port on its server) gets its connection address on the new server. Apps linked to it show pending changes.
- No room:
db is waiting for room in eu: server-a stopped answering and no other server has room yet. It is retried every 30 seconds, with the same alert as apps. The Failover card shows Waiting for room in eu. - A password or a setting you just changed reaches the leader with the next backup. A failover in that window restores with the previous ones.
When a database does not fail over
Activity says why, once a day:
| Activity says | Fix |
|---|---|
db cannot fail over yet: its backups are kept on server-a, the server it runs on, so they would stop with it. Pick another destination for its backup. Cluster eu will not move it to another server until that is fixed. | Move its backup to a bucket or to another server of the cluster |
db cannot fail over yet: its backups are kept on server-x, which is not in the cluster, so no server of the cluster can read them on its own. Keep its backup on another server of the cluster, or in a bucket. Cluster eu will not move it to another server until that is fixed. | Same |
The server agent on server-b is too old to restore a database when another server in cluster eu stops. Deplo updates it on its own. | Nothing to do: wait |
Until its first backup has finished, a database waits for its server.
After a failover or a move onto the server that keeps its backups, the database's page warns: "db now runs on server-b, the server its backups are kept on. If server-b stops, the backups go with it. Pick another destination for its backup." with a Backups link. It will not fail over again until its backup goes elsewhere.
Names across servers
An app reaches its environment's database by the same name, db-<slug>, on whichever server of
the cluster either of them runs. No connection string changes after a move or a failover.
- Names never cross environments, teams or clusters. An app with no environment shares names with the team's other apps and databases that have none. See Network isolation.
- Every app reaches it, whatever its kind: a single-image app, or any service of a Compose app.
- Between two servers the traffic goes over the cluster's private network, directly when the two can reach each other. The cluster still places an app next to its environment's database when it can.
When a pair of servers cannot reach each other directly, their traffic goes through Deplo's relay and the database's page says so: "web reaches this database through Deplo's relay. It is faster on the same server."
An older server agent is named in the deploy log: "The server agent on this server is too old to keep names working across the servers of its cluster. Deplo updates it on its own."
The pickers say the same rule. On a cluster, the Environment field of Create database reads: "Apps reach this database by name only from the same environment, on any server of the cluster." And Move to environment: "Apps reach a database by name only from the same environment, on the same server or cluster".
Over the API
createDatabase(input: { clusterId }), moveDatabaseToCluster(id, clusterId), and
Database.clusterId / clusterName. Over MCP: create_database takes clusterId, and
move_database_to_cluster moves one.
Did this page help you?