Skip to content
Starting November 2023 Percona XtraBackup 2.4 has reached EOL status. If you have 5.7 databases, we encourage you to upgrade to 8.0 and then install Percona XtraBackup 8.0. Learn more

logo
Percona XtraBackup
Making an Incremental Backup
Initializing search
    percona/pxb-docs
    percona/pxb-docs
    • Home
      • About Percona XtraBackup
      • How Percona XtraBackup Works
      • Understand version numbers
      • Installing Percona XtraBackup 2.4
      • Installing Percona XtraBackup on Debian and Ubuntu
      • Installing Percona XtraBackup on Red Hat Enterprise Linux and CentOS
      • Installing Percona XtraBackup from a Binary Tarball
      • Compiling and Installing from Source Code
      • Running Percona XtraBackup in a Docker container
      • Connection and Privileges Needed
      • Configuring xtrabackup
      • The Backup Cycle - Full Backups
      • Incremental Backup
      • Compressed Backup
      • Encrypted Backup
      • Percona XtraBackup User Manual
      • Throttling Backups
      • Lockless binary log information
      • Encrypted InnoDB Tablespace Backups
      • lock-ddl-per-table Option Improvements
      • How-tos and Recipes
        • Release notes index
        • Percona XtraBackup 2.4.29 (2023-12-18)
        • Percona XtraBackup 2.4.28 (2023-04-04)
        • Percona XtraBackup 2.4.27 (2022-12-06)
        • Percona XtraBackup 2.4.26
        • Percona XtraBackup 2.4.25
        • Percona XtraBackup 2.4.24
        • Percona XtraBackup 2.4.23
        • Percona XtraBackup 2.4.22
        • Percona XtraBackup 2.4.21
        • Percona XtraBackup 2.4.20
        • Percona XtraBackup 2.4.19
        • Percona XtraBackup 2.4.18
        • Percona XtraBackup 2.4.17
        • Percona XtraBackup 2.4.16
        • Percona XtraBackup 2.4.15
        • Percona XtraBackup 2.4.14
        • Percona XtraBackup 2.4.13
        • Percona XtraBackup 2.4.12
        • Percona XtraBackup 2.4.11
        • Percona XtraBackup 2.4.10
        • Percona XtraBackup 2.4.9
        • Percona XtraBackup 2.4.8
        • Percona XtraBackup 2.4.7-2
        • Percona XtraBackup 2.4.7
        • Percona XtraBackup 2.4.6
        • Percona XtraBackup 2.4.5
        • Percona XtraBackup 2.4.4
        • Percona XtraBackup 2.4.3
        • Percona XtraBackup 2.4.2
        • Percona XtraBackup 2.4.1
      • The xtrabackup Option Reference
      • The innobackupex Option Reference
      • The xbcloud Binary
      • Exponential Backoff
      • Using the xbcloud binary with Microsoft Azure Cloud Storage
      • The xbcrypt binary
      • The xbstream binary
      • Known issues and limitations
      • Frequently Asked Questions
      • Glossary
      • Index of files created by Percona XtraBackup
      • Trademark policy
      • Copyright and licensing information
      • Version Checking

    Making an Incremental Backup¶

    Every incremental backup starts with a full one, which we will call the base backup:

    $ innobackupex --user=USER --password=PASSWORD /path/to/backup/dir/
    

    Note that the full backup will be in a timestamped subdirectory of /path/to/backup/dir/ (e.g., /path/to/backup/dir/2011-12-24_23-01-00/).

    Assuming that variable $FULLBACKUP contains /path/to/backup/dir/2011-5-23_23-01-18, let’s do an incremental backup an hour later:

    innobackupex --incremental /path/to/inc/dir \
      --incremental-basedir=$FULLBACKUP --user=USER --password=PASSWORD
    

    Now, the incremental backup should be in /path/to/inc/dir/2011-12-25_00-01-00/. Let’s call $INCREMENTALBACKUP=2011-5-23_23-50-10.

    Preparing incremental backups is a bit different from full ones:

    First you have to replay the committed transactions on each backup,

    $ innobackupex --apply-log --redo-only $FULLBACKUP \
     --use-memory=1G --user=USER --password=PASSWORD
    

    Note

    In the prepare phase, the --use-memory parameter speeds up the process if the amount of RAM assigned to the option is available. Use the parameter only in the prepare phase. In the other phases the parameter makes the application lazy allocate this memory (reserve) but does not affect database pages.

    If everything went fine, you should see an output similar to:

    111225 01:10:12 InnoDB: Shutdown completed; log sequence number 91514213
    

    Now apply the incremental backup to the base backup, by issuing:

    $ innobackupex --apply-log --redo-only $FULLBACKUP
     --incremental-dir=$INCREMENTALBACKUP
     --use-memory=1G --user=DVADER --password=D4RKS1D3
    

    Note the $INCREMENTALBACKUP.

    The final data will be in the base backup directory, not in the incremental one. In this example, /path/to/backup/dir/2011-12-24_23-01-00 or $FULLBACKUP.

    If you want to apply more incremental backups, repeat this step with the next one. It is important that you do this in the chronological order in which the backups were done.

    You can check the file xtrabackup_checkpoints at the directory of each one.

    They should look like: (in the base backup)

    backup_type = full-backuped
    from_lsn = 0
    to_lsn = 1291135
    

    and in the incremental ones:

    backup_type = incremental
    from_lsn = 1291135
    to_lsn = 1291340
    

    The to_lsn number must match the from_lsn of the next one.

    Once you put all the parts together, you can prepare again the full backup (base + incrementals) once again to rollback the pending transactions:

    $ innobackupex-1.5.1 --apply-log $FULLBACKUP --use-memory=1G \
    --user=$USERNAME --password=$PASSWORD
    

    Now your backup is ready to be used immediately after restoring it. This preparation step is optional, as if you restore it without doing it, the database server will assume that a crash occurred and will begin to roll back the uncommitted transaction (causing some downtime which can be avoided).

    Contact us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.

    2022-11-10
    Percona LLC and/or its affiliates, © 2024 Cookie Preferences
    Made with Material for MkDocs