We are scripting a mix of full and incremental backup setup for our prodcut backend with sunday triggering full backup and incremental backup on all the remaining days.

In this process, we should be able to read the LSN number of a file from the full backup file.

We have setup the script to compress the backup into xbstream format so it would result one single file compressing all the data.

Now the question is how to extract or read the LSN or one single info file from the complete xbstream file.

Though we can use log file for this, we wanted a more dependable solution.

Thank you.

1 Answer 1


XtraBackup logs the most recent LSN not only in xtrabackup_info which you'll have to extract, but to STDERR, too:

150731 16:33:28  innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
150731 16:33:28  innobackupex: Waiting for log copying to finish

xtrabackup: The latest check point (for incremental): '1948062848'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1948062848)

The LSN would be 1948062848. Find string xtrabackup: The latest check point (for incremental): in the output. See http://bazaar.launchpad.net/~twindb-dev/twindb-agent/trunk/view/head:/twindb.py#L1888 for example:

def grep_lsn(output):
    Finds LSN in XtraBackup output
    :param output: string with Xtrabackup output
    :return: LSN
    lsn = None
    for line in output.split("\n"):
        if line.startswith("xtrabackup: The latest check point (for incremental):"):
            lsn = line.split("'")[1]
    return lsn

Then, pass 1948062848 with --incremental-lsn= option when you take an incremental copy. Example: http://bazaar.launchpad.net/~twindb-dev/twindb-agent/trunk/view/head:/twindb.py#L1429

if backup_type == 'incremental':
    last_lsn = job["params"]["lsn"]
    xtrabackup_cmd.append("--incremental-lsn=%s" % last_lsn)
  • Nice answer. You may want to consider putting the salient points from the links into the answer to preserve the details for future readers. Thanks!
    – Hannah Vernon
    Jul 31, 2015 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.