Point-In-Time Recovery (InnoDB Log Archiving)

This functionality is available from MariaDB 13.0.

When InnoDB log archiving is enabled, the server retains a continuous history of write-ahead log records across multiple ib_lsn.log files. You can use this history to perform point-in-time recovery (PITR) to a specific Log Sequence Number (LSN), by replaying the archived InnoDB write-ahead logs at server startup.

This is an alternative to PITR via mariadb-backup and binary logs, useful in InnoDB-only deployments or in recovery scenarios where binary logs are not available.

Recovery Parameters

Two startup parameters define the range of the log replay:

  • innodb_log_recovery_start — the LSN at which recovery begins. Set this to the end LSN of the previous restore when applying an incremental restore. The default 0 starts from the latest completed checkpoint, which is guaranteed to live in one of the last two ib_lsn.log files.

  • innodb_log_recovery_target — the LSN at which recovery ends (the recovery point objective). When this is non-zero, persistent InnoDB tables become read-only and no log writes are allowed during the recovery session. The default 0 replays the log to its end.

You can identify candidate LSNs from the Innodb_lsn_archived status variable on the source server, and from the file names in the data directory (each ib_lsn.log file name encodes the LSN at file offset 0x3000).

The data files in the restore must correspond to an LSN that lies between Innodb_lsn_archived (the first checkpoint in the first archived log file) and the end LSN of the last archived log file. To extend the available recovery range, copy additional archived log files in from the source server — no further copying of data files is required.

Procedure

1

Prepare the restore.

Place the restored InnoDB data files and the corresponding ib_lsn.log archive files in the data directory. With innodb_log_archive=ON, the server refuses to start if a legacy ib_logfile0 exists, so make sure it is not present.

2

Stop the MariaDB Server (if it is running).

$ sudo systemctl stop mariadb
3

Start the server with recovery parameters.

Pass innodb_log_recovery_start and innodb_log_recovery_target either on the command line or in the configuration file, alongside innodb_log_archive=ON. While innodb_log_recovery_target is non-zero, the server replays the archived log up to the target LSN and then keeps the InnoDB tables read-only.

4

Verify the state.

Once the server reaches the target LSN, the recovery process stops. Inspect Innodb_lsn_archived, Innodb_lsn_current, and the contents of the recovered tables to confirm the data is at the expected logical point.

5

Resume normal operation.

To return to normal read-write operation, restart the server without innodb_log_recovery_target set.

Point-in-time recovery of DDL operations is limited even for an InnoDB-only deployment, because part of the data dictionary is stored in .frm files whose creation is not covered by the InnoDB write-ahead log.

See Also

Last updated

Was this helpful?