How to use xtrabackup command from different server to backup mysql

Hi,
I’ve mysql running on a pod, and xtrabackup running on another pod. I want to backup the mysql database from the xtrabackup pod using xtrabackup command. Basically, I want to run the xtrabackup command from another server rather than my mysql server. Is it possible? How xtrabackup maintain mysql data directory access?
Thank you.

Hi @arman, this is not possible. xtrabackup requires file access to MySQL’s data directory. You can’t run it in another pod. You need to run it inside the same container as MySQL. From inside the MySQL container, you can run xtrabackup and stream it directly to S3-compatible storage, or stream it to another location using smb/nfs/scp/etc.

Hi @matthewb, Thank you for your reply and information. I got your point. I’ve a question regarding your solution. Does xtrabackup work if I give the data directory access to xtrabackup server? I mean,If I want to run the xtrabackup as side-car container along with mysql container and mount the data-directory to xtrabackup container, is that work? Or is it strict that, we need to run in same container?
Thank you.

Hey @arman,
Have a look at our docs. There’s some stuff in there about PXB in docker.

1 Like

Hi @matthewb, Thank you for your information.
I’m facing an error, xtrabackup: File '/var/lib/mysql/binlog.000004' not found (OS errno 2 - No such file or directory) 2024-10-08T05:14:37.313046-00:00 0 [ERROR] [MY-011825] [Xtrabackup] copy_file() failed.

I had 3 binary log file when run xtrabackup command. So why xtrabackup tring to fetch 4th binary log file. Although the backup is failing, but it successfully flush the binary log and now there are 4 binary logs.
I think this is known issue. Can you pls guide me to resolve? Am I missing something?

version:
xtrabackup: xtrabackup version 8.0.35-31 based on MySQL server 8.0.35 Linux (x86_64) (revision id: 55ec21d7)
mysql: Ver 8.0.35 for Linux on x86_64 (MySQL Community Server - GPL)

PXB should execute a FLUSH BINARY LOGS early in execution. This should have created your 4th binlog. Do you store binlogs in /var/lib/mysql/ ? Is that the same path you mounted in PXB container?

Yes, I store binlogs in /var/lib/mysql. But in PXB container I mount the datadirectory path as /tm/var/lib/mysql, and pass --datadir=/tm/var/lib/mysql flag when run xtrabackup. Is that the issue?