MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
768 stars 438 forks source link

Initialize via mariabackup #533

Closed grooverdan closed 11 months ago

grooverdan commented 12 months ago

please review closely.

The mariadb-backup must be prepared and tarred up.

might need to look at the owner of extracted files.

mmontes11 commented 12 months ago

I can confirm it works as expected. Steps followed to test it with mariadb-operator:

This suits the needs of the operator. Thanks for this feature 🙏🏻

fauust commented 11 months ago

might need to look at the owner of extracted files.

probably yes.

Also, I am missing the documentation on how this is supposed to work. For instance this is probably not going to work if the backup was created with:

sudo tar -czf backup.tgz /var/lib/mysql_backup/

Speaking of that I would love to see the .xb format supported too and this makes me think if we should not use an environment variable for specifying the backup file. It would probably make it easier to support more formats and extensions.

fauust commented 11 months ago

On .xb (mbstream format), it's particularly useful for off-sites backups and when coupling mariabackup with restic or borgbackup solutions. Here are the commands to restore the backup:

mkdir restore && cd restore
mbstream -x <../mariadb.xb
mariabackup --prepare --target-dir=.
grooverdan commented 11 months ago

might need to look at the owner of extracted files.

probably yes.

done.

Also, I am missing the documentation on how this is supposed to work.

Right. The general premises is its a tarball of the datadir taken from the datadir as a working directory (and mariadb stopped). The alternate is a prepared backup per the test case.

For instance this is probably not going to work if the backup was created with:

sudo tar -czf backup.tgz /var/lib/mysql_backup/

Yep, on two levels, .tgz isn't in the extension list, easy enough to added.

Second depth, there are ways it could be added/detected. I'm just not sure I want to implement it.

Is a [ ! -f mysql/user.frm ] && mysql_error 'backup not at right level' acceptable?

Speaking of that I would love to see the .xb format supported too

I've no general objection, could be added in a separate PR. It wasn't my first preference as the mariadb-backup --prepare need to be the same version as where it was backed up. If you attempt a restore on a newer version it would fail.

and this makes me think if we should not use an environment variable for specifying the backup file. It would probably make it easier to support more formats and extensions.

Do you foresee a conflict in the backup file and the mechanism required for restore?

grooverdan commented 11 months ago

@fauust just checking you are ok with the last two commits, especially changing the homedir and using /var/lib/mysql as a configuration location? The though was that if there where specific configuration settings needed that pertain to the backup, for restore, then then need to be set, preferably somewhere that is permanent.