Skip to content
logo
Percona XtraBackup
Run Percona XtraBackup in a Docker container
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
        • Scope of this section
        • 1. Install Docker
        • 2. Connect to a Percona Server for MySQL container
        • 3. Create a Docker container from Percona XtraBackup image
      • 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
      • 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
      • 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.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

    • Scope of this section
    • 1. Install Docker
    • 2. Connect to a Percona Server for MySQL container
    • 3. Create a Docker container from Percona XtraBackup image

    Run Percona XtraBackup in a Docker container¶

    Docker allows you to run applications in a lightweight unit called a container.

    You can run Percona XtraBackup in a Docker container without installing the product. All required libraries are available in the container. Being a lightweight execution environment, Docker containers enable creating configurations where each program runs in a separate container. You may run Percona Server for MySQL in one container and Percona XtraBackup in another. Docker images offer a range of options.

    Create a Docker container based on a Docker image. Docker images for Percona XtraBackup are hosted publicly on Docker Hub.

    $ sudo docker create ... percona/percona-xtrabackup --name xtrabackup ...
    

    Scope of this section¶

    This section demonstrates how to back up data on a Percona Server for MySQL running in another Dockers container.

    1. Install Docker¶

    Your operating system may already provide a package for docker. However, the versions of Docker provided by your operating system are likely to be outdated.

    Use the installation instructions for your operating system available from the Docker site to set up the latest version of docker.

    2. Connect to a Percona Server for MySQL container¶

    Percona XtraBackup works in combination with a database server. When running a Docker container for Percona XtraBackup, you can make backups for a database server either installed on the host machine or running in a separate Docker container.

    To set up a database server on a host machine or in Docker container, follow the documentation of the supported product that you intend to use with Percona XtraBackup.

    See also

    Docker volumes as container persistent data storage

    More information about containers

    $ sudo docker run -d --name percona-server-mysql \
    -e MYSQL_ROOT_PASSWORD=root percona/percona-server:8.0
    

    As soon as Percona Server for MySQL runs, add some data to it. Now, you are ready to make backups with Percona XtraBackup.

    Important

    When running Percona XtraBackup from a container and connecting to a MySQLserver container, we recommend using the –user root option in the Docker command.

    3. Create a Docker container from Percona XtraBackup image¶

    You can create a Docker container based on Percona XtraBackup image with either docker create or the docker run command. docker create creates a Docker container and makes it available for starting later.

    Docker downloads the Percona XtraBackup image from the Docker Hub. If it is not the first time you use the selected image, Docker uses the image available locally.

    $ sudo docker create --name percona-xtrabackup --volumes-from percona-server-mysql \
    percona/percona-xtrabackup  \
    xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/backup \
    --user=root --password=mysql
    

    With parameter name you give a meaningful name to your new Docker container so that you could easily locate it among your other containers.

    The volumes-from flag refers to Percona Server for MySQL and indicates that you intend to use the same data as the Percona Server for MySQL container.

    Run the container with exactly the same parameters that were used when the container was created:

    $ sudo docker start -ai percona-xtrabackup
    

    This command starts the percona-xtrabackup container, attaches to its input/output streams, and opens an interactive shell.

    The docker run is a shortcut command that creates a Docker container and then immediately runs it.

    $ sudo docker run --name percona-xtrabackup --volumes-from percona-server-mysql \
    percona/percona-xtrabackup
    xtrabackup --backup --data-dir=/var/lib/mysql --target-dir=/backup --user=root --password=mysql
    

    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
    Back to top
    Previous Uninstall Percona XtraBackup
    Next Implementation details
    Percona LLC and/or its affiliates, © 2023
    Made with Material for MkDocs