I have MariaDB running in a Docker container with the container's data directory
/var/lib/mysql/ mapped to the host directory
I want to run
mariabackup from the host to create a physical backup of the data directory (which is
/mnt/data as far as the host is concerned and
/var/lib/mysql/ from the container's perspective).
I get an error, however, running
mariabackup that says it cannot find the data directory:
$ mariabackup --backup --user=backup --stream=xbstream -h /mnt/data/ | gzip > foo.gz Connecting to MySQL server host: 127.0.0.1, user: backup, password: set, port: 3306 ... Using server version 10.3.10-MariaDB-1:10.3.10+maria~bionic Warning: MySQL variable 'datadir' points to nonexistent directory '/var/lib/mysql/' Warning: option 'datadir' has different balues: '/mnt/data/' in defaults file '/var/lib/mysql/' in SHOW VARIABLES mariabackup based on MariaDB server 10.1.29-MariaDB debian-linux-gnu (x86_54) mariabackup: uses posix_fadvise(). mariabackup: Can't change dir to '/var/lib/mysql/ (Errcode: 2 "No such file or directory") mariabackup: cannot my_setwd /var/lib/mysql/
Something similar happens when I don't specify the data directory with the
-h flag. I expected
/mnt/data/, execute the commands it needs to run on the server, and everything to simply work because it doesn't seem like it should matter what
SHOW VARIABLES says if there's a valid data directory at
- I understand the warning that
mariabackupsees two different paths for
datadir, one that I provided via
-hand another on the server.
- Why, however, does
/var/lib/mysql/when I explicity said (via the
-hflag) that the data directory is
/mnt/data/? Can I get
mariabackupto ignore what the server says and
cdto the directory I provided?
- If my approach is all wrong, what's the best way to do physical backups of a server running in a container with data directory mapped to a host directory?