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
Running 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
      • 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
        • Scope of this section
        • Installing Docker
        • Connecting to a Percona Server for MySQL container
        • Creating a Docker container from Percona XtraBackup image
      • 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

    • Scope of this section
    • Installing Docker
    • Connecting to a Percona Server for MySQL container
    • Creating a Docker container from Percona XtraBackup image

    Running Percona XtraBackup in a Docker container¶

    Note

    The following instructions runs Percona XtraBackup 2.4 in a Docker container. The instructions to run Percona XtraBackup 8.0 by the same method are available in the Percona XtraBackup 8.0 Docker documentation.

    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 at percona/percona-xtrabackup.

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

    Scope of this section¶

    This section demonstrates how to backup data on a Percona Server for MySQL running in another Docker container.

    Installing 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.

    Note

    Docker Documentation: * How to use Docker * Installing * Getting started

    Connecting 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

    Percona Server for MySQL Documentation: * Installing on a host machine * Running in a Docker container

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

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

    Creating a Docker container from Percona XtraBackup image¶

    You can create a Docker container based on Percona XtraBackup image with either docker create or 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-2.4 --volumes-from percona-server-mysql-5.7 \
    percona/percona-xtrabackup:2.4  \
    xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/backup \
    --user=root --password=mysql
    

    With --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 referring to percona-server-mysql indicates that you indend to use the same data as the percona-server-mysql container.

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

    $ sudo docker start -ai percona-xtrabackup-2.4
    

    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-2.4 --volumes-from percona-server-mysql-5.7 \
    percona/percona-xtrabackup:2.4
    xtrabackup --backup --data-dir=/var/lib/mysql --target-dir=/backup --user=root --password=mysql
    

    See also

    More in Docker documentation * Docker volumes as persistent data storage for containers * More information about containers

    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.

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