Skip to content
logo
Percona XtraBackup
Create a full backup
Initializing search
    percona/pxb-docs
    percona/pxb-docs
    • Home
      • Release notes index
      • Percona XtraBackup 8.0.35-30 (2023-12-04)
      • Percona XtraBackup 8.0.34-29 (2023-08-21)
      • Percona XtraBackup 8.0.33-28 (2023-07-19)
      • Percona XtraBackup 8.0.33-27 (2023-05-25)
      • Percona XtraBackup 8.0.32-26 (2023-04-04)
      • 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
      • About Percona XtraBackup
      • How Percona XtraBackup works
      • Understand version numbers
        • LRU dump backup
        • Throttling backups
        • Store backup history on the server
        • Dictionary cache
        • Point-in-time recovery
        • Restore individual tables
      • Encrypted InnoDB tablespace backups
      • FLUSH TABLES WITH READ LOCK option
      • Improved log statements
      • lock-ddl-per-table option improvements
      • Smart memory estimation
      • Work with binary logs
      • Overview
        • The xtrabackup binary overview
        • xtrabackup implementation details
        • Configure xtrabackup
        • Analyze table statistics
      • The xbcrypt binary overview
        • The xbstream binary overview
        • Take a streaming backup
        • Accelerate the backup process
        • Encrypt backups
        • The xbcloud binary overview
          • Use the xbcloud binary with Amazon S3
          • Use the xbcloud binary with an IAM instance profile
          • Use the xbcloud binary with Swift
          • Use the xbcloud binary with Google Cloud Storage
          • Use the xbcloud binary with Microsoft Azure Cloud Storage
          • Use the xbcloud binary with MinIO
        • Update curl utility
        • FIFO data sink
        • Exponential backoff
      • Quickstart Guide for Percona XtraBackup
      • Install Percona XtraBackup 8.0 overview
        • Server version and backup version comparison
        • Connection and privileges needed
        • Permissions needed
        • Use APT repositories
        • Files in DEB package
        • Downloaded DEB packages
        • Apt pinning
        • Work with AppArmor
        • Uninstall
        • Use RPM repositories
        • Files in RPM package
        • Downloaded RPM packages
        • Work with SELinux
        • Uninstall
        • Install with binary tarballs
        • Binary tarballs available
        • Compile and install Percona XtraBackup 8.0 from source
        • Run Percona XtraBackup 8.0 in a Docker container
        • Create a full backup
        • Prepare a full backup
        • Create an incremental backup
        • Prepare an incremental backup
        • Take an incremental backup using page tracking
        • Create a compressed backup
        • Decompress and prepare a compressed backup
        • Create a partial backup
        • Prepare a partial backup
        • Create an individual partitions backup
        • Prepare an individual partitions backup
        • Restore full, incremental, compressed backups
        • Restore a partial backup
        • Restore an individual partitions backup
        • How to set up a replica for replication in 6 simple steps with Percona XtraBackup
        • How to create a new (or repair a broken) GTID-based replica
        • Make backups in replication environments
        • Verify backups with replication and pt-checksum
      • Error Message: Found tables with row versions due to INSTANT ADD/DROP columns
      • xtrabackup exit codes
      • Topic index
      • The xtrabackup option reference
      • Index of files created by Percona XtraBackup
      • Frequently asked questions
      • Glossary
      • Percona Toolkit version checking
      • Trademark policy
      • Copyright and licensing information

    Create a full backup¶

    To create a backup, run xtrabackup with the --backup option. You also need to specify the --target-dir option, which is where the backup will be stored, if the InnoDB data or log files are not stored in the same directory, you might need to specify the location of those, too. If the target directory does not exist, xtrabackup creates it. If the directory does exist and is empty, xtrabackup will succeed.

    xtrabackup will not overwrite existing files, it will fail with operating system error 17, file exists.

    To start the backup process run:

    $ xtrabackup --backup --target-dir=/data/backups/
    

    This will store the backup at /data/backups/. If you specify a relative path, the target directory will be relative to the current directory.

    During the backup process, you should see a lot of output showing the data files being copied, as well as the log file thread repeatedly scanning the log files and copying from it. Here is an example that shows the log thread scanning the log in the background, and a file copying thread working on the ibdata1 file:

    Expected output
    160906 10:19:17 Finished backing up non-InnoDB tables and files
    160906 10:19:17 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
    xtrabackup: The latest check point (for incremental): '62988944'
    xtrabackup: Stopping log copying thread.
    .160906 10:19:18 >> log scanned up to (137343534)
    160906 10:19:18 Executing UNLOCK TABLES
    160906 10:19:18 All tables unlocked
    160906 10:19:18 Backup created in directory '/data/backups/'
    160906 10:19:18 [00] Writing backup-my.cnf
    160906 10:19:18 [00]        ...done
    160906 10:19:18 [00] Writing xtrabackup_info
    160906 10:19:18 [00]        ...done
    xtrabackup: Transaction log of lsn (26970807) to (137343534) was copied.
    160906 10:19:18 completed OK!
    

    The last thing you should see is something like the following, where the value of the <LSN> will be a number that depends on your system:

    $ xtrabackup: Transaction log of lsn (<SLN>) to (<LSN>) was copied.
    

    Note

    Log copying thread checks the transactional log every second to see if there were any new log records written that need to be copied, but there is a chance that the log copying thread might not be able to keep up with the amount of writes that go to the transactional logs, and will hit an error when the log records are overwritten before they could be read.

    After the backup is finished, the target directory will contain files such as the following, assuming you have a single InnoDB table test.tbl1 and you are using MySQL’s innodb_file_per_table option:

    $ ls -lh /data/backups/
    

    The result should look like this:

    Expected output
    total 182M
    drwx------  7 root root 4.0K Sep  6 10:19 .
    drwxrwxrwt 11 root root 4.0K Sep  6 11:05 ..
    -rw-r-----  1 root root  387 Sep  6 10:19 backup-my.cnf
    -rw-r-----  1 root root  76M Sep  6 10:19 ibdata1
    drwx------  2 root root 4.0K Sep  6 10:19 mysql
    drwx------  2 root root 4.0K Sep  6 10:19 performance_schema
    drwx------  2 root root 4.0K Sep  6 10:19 sbtest
    drwx------  2 root root 4.0K Sep  6 10:19 test
    drwx------  2 root root 4.0K Sep  6 10:19 world2
    -rw-r-----  1 root root  116 Sep  6 10:19 xtrabackup_checkpoints
    -rw-r-----  1 root root  433 Sep  6 10:19 xtrabackup_info
    -rw-r-----  1 root root 106M Sep  6 10:19 xtrabackup_logfile
    

    The backup can take a long time, depending on how large the database is. It is safe to cancel at any time, because xtrabackup does not modify the database.

    The next step is to prepare the backup in order to restore it.

    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: 2023-06-12
    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. Read more about Percona Cookie Policy.