Innobackupex: How to extract individual files from xbstream compressed backups 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.
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.
.&gt;&gt; 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")
    xtrabackup_cmd.append(".")
    xtrabackup_cmd.append("--incremental-lsn=%s" % last_lsn)