Running Percona XtraBackup on Windows ... in Docker - Percona Database Performan...
source link: https://www.percona.com/blog/2017/03/20/running-percona-xtrabackup-windows-docker/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Running Percona XtraBackup on Windows … in Docker
In this blog, we’ll look at running Percona XtraBackup on Windows via a Docker container.
The question whether Percona XtraBackup is available for Windows comes up every so often. While we are not planning to provide regular releases for Windows, I decided to share a way to run Percona XtraBackup in a Docker container (especially since Docker support for Windows has become more and more stable).
For this exercise, I created a playground Docker image: perconalab/percona-xtrabackup
.
First, we need to prepare a few things to make it work:
- Install Docker on Windows (the current version I am running is 17.03)
- Enable the sharing of disk C in Docker settings
- Find out the IP address MySQL is running on (
192.168.1.122
in my case) - Grant backup-required privileges for the
xtrabackup
user:
GRANT RELOAD,PROCESS,LOCK TABLES,REPLICATION CLIENT ON *.* TO 'xtrabackup'@'192.%' IDENTIFIED by 'xtrapassword'
Now, let’s assume our datadir is in C:/mysqldata
, and we want to backup to C:/mysqlbackup
. Needless to say, that XtraBackup image must run on the same server as MySQL’s datadir (since XtraBackup needs to access the data to copy it).
Now to take a backup we execute:
docker run --rm -it -v //C/mysqldata:/var/lib/mysql -v //C/mysqlbackup:/xtrabackup_backupfiles perconalab/percona-xtrabackup --backup --host=192.168.1.122 --user=xtrabackup --password=xtrapassword
We find our backup in C:/mysqlbackup
when it is done.
Enjoy!
STAY UP-TO-DATE With Percona!
Join 33,000+ of your fellow open-source enthusiasts! Our newsletter provides updates on Percona open source software releases, technical resources, and valuable MySQL, MariaDB, PostgreSQL, and MongoDB-related articles. Get information about Percona Live, our technical webinars, and upcoming events and meetups where you can talk with our experts.
By submitting my information I agree that Percona may use my personal data in send communication to me about Percona services. I understand that I can unsubscribe from the communication at any time in accordance with the Percona Privacy Policy.
Author
Vadim Tkachenko co-founded Percona in 2006 and serves as its Chief Technology Officer. Vadim leads Percona Labs, which focuses on technology research and performance evaluations of Percona’s and third-party products. Percona Labs designs no-gimmick tests of hardware, filesystems, storage engines, and databases that surpass the standard performance and functionality scenario benchmarks.
Vadim’s expertise in LAMP performance and multi-threaded programming help optimize MySQL and InnoDB internals to take full advantage of modern hardware. Oracle Corporation and its predecessors have incorporated Vadim’s source code patches into the mainstream MySQL and InnoDB products.
He also co-authored the book High Performance MySQL: Optimization, Backups, and Replication 3rd Edition.
Comments (9)
-
Peter Laursen
I was able to install XtraBackup on “bash in Windows” directly/natively from Ubuntus repository (“sudo apt-get install ..” or use “Synaptic” GUI softare management tool). But I haven’t tested if it works. Have you?
If you don’t know “bash in Windows” you can start here:
https://blog.webyog.com/how-to-add-a-gui-to-the-new-bash-console-in-windows-10/ -
Peter Laursen
It does not seem so:
C:\Users\jazcy>bash
peter@SH-WIN10:/mnt/c/Users/jazcy$ xtrabackup –user=root –password=secret -host=127.0.0.1 –port=3308 –backup –target-dir=\test
prctl() failed with errno = 22
peter@SH-WIN10:/mnt/c/Users/jazcy$No diference if I install rpctl. Maybe “bash in Windows” will not be allowed to get the information from the system it needs or rpctl is simply incompatible with Windows and not translated to Windows system calls on this environment . It would be nice to avoid Docker, so if there is a solution it would be nice
Thoughts?
-
Vadim Tkachenko
Peter,
I did not try bash in Windows, but I will try to see if we can make it running
-
Vadim Tkachenko
Apparently the current bash for Windows does not support prctl system call, but supposedly it will be fixed in Windows 10 Creators Edition
https://msdn.microsoft.com/en-us/commandline/wsl/release_notes
So hopefully it will work better then. -
Vadim Tkachenko
Peter,
I’ve just tested in Windows 10 Creators Edition and the problem is resolved. Windows added support for prctl system call.
-
-
Peter Laursen
correction. no diference if I install prctl
-
Vadim Tkachenko
UPDATE for using percona-xtrabackup image for 2.4.11 version.
The following parameter should be added to the command line:
--innodb-undo-directory=/var/lib/mysql
so the full command looks like:
docker run --rm -it -v //C/mysqldata:/var/lib/mysql -v //C/mysqlbackup:/xtrabackup_backupfiles perconalab/percona-xtrabackup --backup --host=192.168.1.122 --user=xtrabackup --password=xtrapassword --innodb-undo-directory=/var/lib/mysql
-
LongFly
Is incremental backup supported?
-
Amine
PS C:\Users\Dell> docker run –rm -it -v //C//DATA:/var/lib/mysql -v //C/mysqlbackup:/xtrabackup_backupfiles perconalab/percona-xtrabackup –backup –host=localhost –user=xtrabackup –password=xtrapassword
Unable to find image ‘perconalab/percona-xtrabackup:latest’ locally
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Get https://registry-1.docker.io/v2/perconalab/percona-xtrabackup/manifests/latest: unauthorized: incorrect username or password.
See ‘C:\Program Files\Docker\Docker\Resources\bin\docker.exe run –help’.can you help me please
Comments are closed.
Use Percona's Technical Forum to ask any follow-up questions on this blog topic.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK