Skip to content
logo
Percona XtraBackup
Verify backups with replication and pt-checksum
Initializing search
    percona/pxb-docs
    percona/pxb-docs
    • Home
      • About Percona XtraBackup
      • How Percona XtraBackup works
      • Understand version numbers
      • Install Percona XtraBackup 8.0
      • Use an APT repo to install Percona XtraBackup
      • Use a YUM repo to install Percona XtraBackup
      • Use DEB or RPM downloaded packages to install Percona XtraBackup
      • Install Percona XtraBackup from a Binary Tarball
      • Compile and install Percona XtraBackup from source code
      • What’s in the packages
      • Uninstall Percona XtraBackup
      • Run Percona XtraBackup in a Docker container
      • Implementation details
      • Connection and privileges needed
      • Configure xtrabackup
      • Server version and backup version comparison
      • xtrabackup exit codes
      • The backup cycle - full backups
      • Incremental backup
      • Compressed backup
      • Partial backups
      • Percona XtraBackup user manual
      • Throttling backups
      • Encrypted InnoDB tablespace backups
      • Encrypt backups
      • LRU dump backup
      • Point-in-time recovery
      • Restore individual tables
      • Smart memory estimation
      • Work with binary logs
      • Improved log statements
      • Work with SELinux
      • Work with AppArmor
      • Enable the server to communicate via TCP/IP
      • Install and configure an SSH server
      • Analyze table statistics
      • FLUSH TABLES WITH READ LOCK option
      • lock-ddl-per-table option improvements
      • Take an incremental backup using page tracking
      • The xbcloud binary
      • Use the xbcloud binary with Swift
      • Use xbcloud Binary with Amazon S3
      • Xbcloud with an IAM instance profile
      • Use the xbcloud binary with MinIO
      • Use the xbcloud with Google Cloud Storage
      • Exponential backoff
      • Use the xbcloud binary with Microsoft Azure Cloud Storage
      • How-tos and recipes
      • Release notes index
      • Percona XtraBackup 8.0.32-25 (2023-02-27)
      • Percona XtraBackup 8.0.31-24 (2023-02-07)
      • Percona XtraBackup 8.0.30-23 (2022-11-14)
      • Percona XtraBackup 8.0.29-22 (2022-07-19)
      • Percona XtraBackup 8.0.28-21 (2022-05-25)
      • Percona XtraBackup 8.0.28-20
      • Percona XtraBackup 8.0.27-19
      • Percona XtraBackup 8.0.26-18.0
      • Percona XtraBackup 8.0.25-17.0
      • Percona XtraBackup 8.0.23-16.0
      • Percona XtraBackup 8.0.22-15.0
      • Percona XtraBackup 8.0.14
      • Percona XtraBackup 8.0.13
      • Percona XtraBackup 8.0.12
      • Percona XtraBackup 8.0.11
      • Percona XtraBackup 8.0.10
      • Percona XtraBackup 8.0.9
      • Percona XtraBackup 8.0.8
      • Percona XtraBackup 8.0.7
      • Percona XtraBackup 8.0.6
      • Percona XtraBackup 8.0.5
      • Percona XtraBackup 8.0.4
      • Percona XtraBackup 8.0-3-rc1
      • Error Message: Found tables with row versions due to INSTANT ADD/DROP columns
      • The xtrabackup option reference
      • The xbcrypt binary
      • The xbstream binary
      • Frequently asked questions
      • Glossary
      • Index of files created by Percona XtraBackup
      • Trademark policy
      • Copyright and licensing information
      • Version checking

    • Set up the replication
    • Use pt-table-checksum

    Verify backups with replication and pt-checksum¶

    One way to verify if the backup is consistent is by setting up the replication and running pt-table-checksum. This can be used to verify any type of backups, but before setting up replication, backup should be prepared and be able to run (this means that incremental backups should be merged to full backups, encrypted backups decrypted etc.).

    Set up the replication¶

    How to set up a replica for replication in 6 simple steps with Percona XtraBackup guide provides a detailed instructions on how to take the backup and set up the replication.

    For checking the backup consistency you can use either the original server where the backup was taken, or another test server created by using a different backup method (such as cold backup, mysqldump or LVM snapshots) as the source server in the replication setup.

    Use pt-table-checksum¶

    This tool is part of the Percona Toolkit. It performs an online replication consistency check by executing checksum queries on the source, which produces different results on replicas that are inconsistent with the source.

    After you confirmed that replication has been set up successfully, you can install or download pt-table-checksum. This example shows downloading the latest version of pt-table-checksum:

    $ wget percona.com/get/pt-table-checksum
    

    Note

    In order for pt-table-checksum to work correctly libdbd-mysql-perl will need to be installed on Debian/Ubuntu systems or perl-DBD-MySQL on RHEL/CentOS. If you installed the percona-toolkit package from the Percona repositories package manager should install those libraries automatically.

    After this command has been run, pt-table-checksum will be downloaded to your current working directory.

    Running the pt-table-checksum on the source will create percona database with the checksums table which will be replicated to the replicas as well. Example of the pt-table-checksum will look like this:

    $ ./pt-table-checksum
    

    The results are similar to the following:

    Expected output
    TS ERRORS  DIFFS     ROWS  CHUNKS SKIPPED    TIME TABLE
    04-30T11:31:50      0      0   633135       8       0   5.400 exampledb.aka_name
    04-30T11:31:52      0      0   290859       1       0   2.692 exampledb.aka_title
    Checksumming exampledb.user_info:  16% 02:27 remain
    Checksumming exampledb.user_info:  34% 01:58 remain
    Checksumming exampledb.user_info:  50% 01:29 remain
    Checksumming exampledb.user_info:  68% 00:56 remain
    Checksumming exampledb.user_info:  86% 00:24 remain
    04-30T11:34:38      0      0 22187768     126       0 165.216 exampledb.user_info
    04-30T11:38:09      0      0        0       1       0   0.033 mysql.time_zone_name
    04-30T11:38:09      0      0        0       1       0   0.052 mysql.time_zone_transition
    04-30T11:38:09      0      0        0       1       0   0.054 mysql.time_zone_transition_type
    04-30T11:38:09      0      0        8       1       0   0.064 mysql.user
    

    If all the values in the DIFFS column are 0 that means that backup is consistent with the current setup.

    In case backup was not consistent pt-table-checksum should spot the difference and point to the table that does not match. Following example shows adding new user on the backed up replica in order to simulate the inconsistent backup:

    mysql> grant usage on exampledb.* to exampledb@localhost identified by 'thisisnewpassword';
    

    If we run the pt-table-checksum now difference should be spotted

    $ ./pt-table-checksum
    

    The results are similar to the following:

    Expected output
    TS ERRORS  DIFFS     ROWS  CHUNKS SKIPPED    TIME TABLE
    04-30T11:31:50      0      0   633135       8       0   5.400 exampledb.aka_name
    04-30T11:31:52      0      0   290859       1       0   2.692 exampledb.aka_title
    Checksumming exampledb.user_info:  16% 02:27 remain
    Checksumming exampledb.user_info:  34% 01:58 remain
    Checksumming exampledb.user_info:  50% 01:29 remain
    Checksumming exampledb.user_info:  68% 00:56 remain
    Checksumming exampledb.user_info:  86% 00:24 remain
    04-30T11:34:38      0      0 22187768     126       0 165.216 exampledb.user_info
    04-30T11:38:09      0      0        0       1       0   0.033 mysql.time_zone_name
    04-30T11:38:09      0      0        0       1       0   0.052 mysql.time_zone_transition
    04-30T11:38:09      0      0        0       1       0   0.054 mysql.time_zone_transition_type
    04-30T11:38:09      1      0        8       1       0   0.064 mysql.user
    

    This output shows that source and the replica aren’t in consistent state and that the difference is in the mysql.user table.

    More information on different options that pt-table-checksum provides can be found in the pt-table-checksum documentation.

    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.


    Last update: 2022-12-06
    Percona LLC and/or its affiliates, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.