At 14:07 someone runs DROP TABLE orders against production instead of staging. Your last nightly backup is from 02:00. Restoring it gives you twelve hours of lost orders. What you actually want is the 02:00 backup plus every change up to 14:06:59.
That is point-in-time recovery, or PITR. For MySQL and MariaDB it is built from two pieces you already have: a full backup and the binary log. This post walks through how it works, how to do it by hand, and what tends to go wrong.
What PITR is made of
A full backup (a logical dump, or a physical copy from XtraBackup or mariabackup) is a snapshot at one moment. The binary log is the ordered record of every change committed after that moment. Restore the snapshot, replay the log up to a chosen point, stop. The result is the database as it was at that point.
Three requirements follow from that:
- Binary logging must be on, and on the server whose data you care about.
- The binary logs between the backup and the target time must still exist, unbroken.
- You must know where in the binary log the backup ended.
Check the first one now:
SHOW VARIABLES LIKE 'log_bin';
SHOW VARIABLES LIKE 'binlog_format';
SHOW BINARY LOGS;Use binlog_format = ROW unless you have a specific reason not to. Row events replay deterministically, and they make it possible to inspect what a bad statement actually changed.
The retention trap
The binary log on the server is not an archive. It is purged automatically, controlled by binlog_expire_logs_seconds (or expire_logs_days on older versions). If your retention is three days and your last good full backup is five days old, there is a two-day hole in the chain and PITR to anywhere in it is impossible.
Two rules prevent this. First, the archive of binary logs must live somewhere other than the database host, because a dead disk takes the logs with it. Second, copy logs off the host more often than you rotate them away. Only closed binary log files are safe to copy, so the interval at which you rotate and ship is the practical limit on how much you lose if the whole server disappears.
Doing it by hand
Assume you restored the 02:00 physical backup onto a scratch host, and you have the binary logs from that day. First, find where the backup ended. For XtraBackup that is in xtrabackup_binlog_info inside the backup (mariabackup writes an equivalent *_binlog_info file, and the exact name depends on the version):
cat xtrabackup_binlog_info
binlog.000042 8312044Next, find the bad statement. Decode the row events around the time and search:
mysqlbinlog --verbose --base64-output=decode-rows \
--start-datetime="2026-11-27 14:00:00" \
--stop-datetime="2026-11-27 14:10:00" \
binlog.000042 binlog.000043 | grep -n -i "drop table"Note the position of the event just before it. Then replay from the backup's position up to that point:
mysqlbinlog --start-position=8312044 \
--stop-position=5120077 \
binlog.000042 binlog.000043 | mysql -u root -pTwo details cause most of the pain here:
--stop-datetimeis interpreted in the time zone of the machine runningmysqlbinlog, not the server that wrote the log. Run it withTZ=UTCand give times in UTC, or use--stop-position, which has no time zone problem at all.- Multiple log files must be passed to a single
mysqlbinloginvocation, in order. Piping separate invocations loses temporary-table state and breaks on--start-position, which applies to the first file only.
On MySQL with GTIDs enabled you can also use --exclude-gtids to skip one specific transaction and keep everything after it, which is sometimes better than stopping before it.
A drill checklist for the chain
You can verify the whole chain without touching production, and you should do it before an incident:
- Pick a full backup and a target time from yesterday.
- Restore the backup on a scratch host.
- Replay the logs up to the target time.
- Compare a row count or checksum on an important table against what you know it held.
- Write down how long the whole thing took. That is your real recovery time.
If a binary log in the range is missing, mysqlbinlog does not complain. It replays the files you give it, and you find out only when the data does not match. Check the sequence of file names for gaps before you start.
What is not covered
Know the limits before you promise a recovery point. PITR with the procedure above applies to a single-writer primary. Galera clusters are different: binary logs are kept per node and are not guaranteed to be identical, so there is no single log to replay against a backup. Containerized databases add their own constraints, since the binary logs live inside the container's storage.
And a restore, by its nature, replaces data. For a single dropped table, restoring the entire server to 14:06:59 throws away everything that happened afterwards, including good work. Often the better path is to recover on a scratch host and copy the one table back.
How this looks in Jarwis ClusterOps
On a MySQL or MariaDB cluster, open the Backup tab and enable binlog archiving. You choose an interval from 1 to 60 minutes, and the default is 5. Jarwis ships the binary logs to the cluster's backup destination, which can be local storage, your organization's remote target (S3, MinIO, Cloudflare R2, Azure Blob, Google Cloud Storage or NFS), or both. To recover, you pick a full backup and a target time, and Jarwis restores the backup and replays the binlogs up to that moment. Before a point-in-time restore starts, the backup file is decrypted and its SHA-256 checksum is checked, and a damaged file is refused instead of half-restored.
A restore replaces everything on the target cluster, and the console warns you before you confirm. Point-in-time recovery is not available for Galera or for containerized databases, and the console says so instead of hiding the question.
A log_archive_lag alarm fires when the newest archived binary log is more than 30 minutes behind by default, so a stalled archive does not stay silent for a week. The RPO panel on the Backup tab uses the same lag, together with the age of the last good backup, to show your measured recovery point next to the target you set.
Lite is free up to three nodes, and backups and alerting are included. You can look at the Backup tab on a read-only demo at demo.jarwis.com. The details are in the backups docs and in backup assurance.