databacker / mysql-backup

image to enable automated backups of mysql databases in containers
639 stars 180 forks source link

Can we skip tar and/or gz ? #197

Open Glideh opened 2 years ago

Glideh commented 2 years ago

Thank you for this great tool ! Is there a way to skip the tar step ? I usually keep everything in a single sql file so it'd be great to have a simple sql.gz file for me. It would be easier to restore anywhere with a simple command. (like gunzip backup.sql.gz | mysql)

deitch commented 2 years ago

In theory, I think, we probably could. The dumps happen here and here, all ending up in a single temporary directory. That directory is then tarred up as is and passed through compress in a single line here

I would be a bit concerned that sometimes it is tarred and sometimes not, though.

Why couldn't you just run the restore in a single line?

cat backupfile.tgz | gunzip | tar -O -x -f - ${filename}.sql | mysql
Glideh commented 2 years ago

This seems to do the job too (when there is only one file):

tar zxfO backup.sql.tgz | mysql

I took a random example with this command, but I was actually wondering if we could skip tar and/or gz, some times I have only one file and this DB backup contains many images already compressed so trying to gzip is quite long and not incredibly reducing the size.

Do you think it would be worth a config param ? (Maybe I'm the only one interested :) In which case I could do a PR

deitch commented 2 years ago

I am concerned with having different formats inside the resulting artifacts. Granted, the tgz extension does indicate, but even so, it could get confusing.

As for the gzip vs not, we already have support for different compression via an env var. If you want to open a PR to provide a no-compression format, go for it, although I suspect that COMPRESS=cat would do it.