The marketing batch job runs at 14:00 and accidentally truncates the subscribers table. Someone notices at 14:23. You have WAL archiving enabled and a base backup from 03:00. The math says you can restore to 13:59:30 and lose only thirty seconds of writes. The procedure to actually do that on a managed PaaS — what to click, what to wait for, and what tends to surprise you — is what this article is about.
What’s happening
Point-in-time recovery on a managed PaaS database is a three-step operation:
- Restore a base backup taken before the recovery target time, into a new database (the original primary stays running — you don’t overwrite production during the drill).
- Apply archived WAL or binary log segments to roll the new database forward to the recovery target.
- Promote the recovered database (stop recovery, allow writes) and cut the application over to it.
The PaaS UI usually presents step 1 and 2 as a single workflow: “Restore to point in time” → select target timestamp → platform provisions a new database environment with the data as of that moment. Step 3 is on you: the application’s connection string still points at the old primary. The cutover is a configuration change, not a database operation.
The realistic RTO for the platform-managed restore-and-replay phase, on a Jelastic-based PaaS:
- Up to 50 GB database: 15-30 minutes from “click restore” to “database ready.”
- 50-500 GB: 30-90 minutes. Most of this is the platform downloading the base backup from object storage to a new volume.
- 500 GB-2 TB: 1-3 hours. Bandwidth between the object store and the new VM is the limiting factor.
- 2 TB+: 3+ hours. At this size, consider whether you should be running PITR at this layer at all, or whether a delayed replica (always-on, 1-hour lag) is the better protection.
Add to that: 5-15 minutes for application config rotation, 10-30 minutes for application warmup (caches cold, prepared statements regenerating, connection pool refilling).
How to verify
Before you need to use PITR in anger, run the drill. The drill exists to surface the gotchas:
# Jelastic: trigger a restore-to-time on a copy environment
jelastic environment control restore-from-backup \
--envName "acme-prod-db" \
--restoreToEnv "acme-prod-db-restore" \
--restoreTime "2026-05-14T13:59:30Z" \
--session "$JELASTIC_TOKEN"
# Watch the restore progress
watch -n 10 'jelastic environment control get-env-info \
--envName "acme-prod-db-restore" \
--session "$JELASTIC_TOKEN" \
| jq ".env.status"'
For Postgres self-managed restore (in case you’re running outside a UI-driven PaaS or testing the procedure end to end):
# 1. Stop Postgres on the restore target
sudo systemctl stop postgresql-16
# 2. Clear the data directory
sudo -u postgres rm -rf /var/lib/pgsql/16/data/*
# 3. Restore the base backup from object storage
sudo -u postgres pgbackrest --stanza=acme-prod \
--type=time \
--target='2026-05-14 13:59:30+00' \
--target-action=promote \
restore
# 4. Confirm recovery configuration
sudo -u postgres cat /var/lib/pgsql/16/data/postgresql.auto.conf
sudo -u postgres cat /var/lib/pgsql/16/data/recovery.signal
# 5. Start Postgres in recovery mode
sudo systemctl start postgresql-16
# 6. Watch the recovery progress
sudo -u postgres tail -f /var/lib/pgsql/16/data/log/postgresql-*.log
# Look for: "consistent recovery state reached at ..."
# "recovery stopping before commit of transaction ..., time ..."
# "archive recovery complete"
# "database system is ready to accept connections"
# 7. Verify the restore landed at the expected point
sudo -u postgres psql -c "SELECT pg_is_in_recovery();" -- should be false
sudo -u postgres psql -c "SELECT now(), pg_last_xact_replay_timestamp();"
sudo -u postgres psql -d app -c "SELECT count(*) FROM subscribers;"
For MySQL the equivalent procedure uses the base backup plus binary log replay:
# 1. Restore the base dump
gunzip < /var/backups/acme-prod-base-2026-05-14-0300.sql.gz | mysql -u root -p
# 2. Find the binary log position at the restore target time
mysqlbinlog --start-datetime="2026-05-14 03:00:00" \
--stop-datetime="2026-05-14 13:59:30" \
/var/log/mysql/binlog.000042 \
/var/log/mysql/binlog.000043 \
| mysql -u root -p
# 3. Confirm row counts at the target
mysql -u root -p -e "SELECT count(*) FROM acme_app.subscribers;"
The gotchas the drill surfaces:
- Application config doesn’t point at the new endpoint. Your
DATABASE_URLstill references the old primary. The restored data exists; the application can’t see it. - Sequences and AUTO_INCREMENT counters don’t always advance. After restore, INSERT may collide with values that existed before the recovery target. Reset sequences explicitly:
SELECT setval('subscribers_id_seq', max(id)) FROM subscribers; - Replication slots from the old primary don’t carry over. If you had read replicas on the original, they’re now disconnected from the new primary. You’ll need to re-base them (
pg_basebackupagain) or repoint them carefully. - Cache layers (Redis, application caches) have stale data referring to rows that no longer exist. Flush them before reopening to traffic.
- DNS or load balancer config points the application at the wrong target. Whether you swap DNS, swap a load balancer backend, or change the application config, that step is manual and easy to forget under time pressure.
- Time zones in the recovery target.
--restoreTimeparameters are UTC on most platforms. If your operator typed local time, you’ve recovered to the wrong moment.
The fix
The runbook that prevents the drill being a problem when it’s real:
-
Run the drill quarterly, recorded. Pick a random recent timestamp, restore to a parallel environment, verify row counts and a known canary value, document elapsed time per phase. Three drills in and you’ll have a realistic RTO number for your specific data size and platform.
-
Pre-stage the cutover steps in a script. The restore is platform work; the cutover is yours. Have the DNS update, the application config rotation, and the cache flush ready as a single executable on the runbook. Test it during the drill.
-
Document the RTO honestly. A 14-day backup retention means nothing if your RTO for a 1 TB database is 4 hours and your SLA says 1 hour. Either size the database differently, switch to a delayed replica for sub-hour RTOs, or change the SLA to match operational reality.
-
Keep a delayed replica for human-error recovery. A streaming replica with
recovery_min_apply_delay = '1h'is always 1 hour behind the primary. When someone runs the wrong query at 14:23, you don’t restore from object storage — you stop replication on the delayed replica before 13:23 of WAL applies, promote it, and you’re back in five minutes. The base-backup-and-replay path is for when the delayed replica isn’t enough.
Stack Harbor runs the drill on your behalf and rotates the runbook into your operations playbook as part of Cloud PaaS and environment management. If you’d like the next drill to be the recorded one — not the one you find out about during an incident — book a recovery readiness review.