docker-db-backup icon indicating copy to clipboard operation
docker-db-backup copied to clipboard

Script is inconsistent for mysql and pgsql

Open jwillmer opened this issue 3 years ago • 6 comments

The following two functions work differently and I think we should make sure they work the same:

https://github.com/tiredofit/docker-db-backup/blob/89fe25132152aa68301a4a72a11e807dbccb9d26/install/etc/services.available/10-db-backup/run#L179-L226

Case 1:

  • In mysql setting DB_NAME has no effect
  • In pgsql you need to set DB_NAME to make the export work (*)

Case 2:

  • In mysql you can export a file with all DBs when setting SPLIT_DB: FALSE
  • In pgsql it will only export the DB set in DB_NAME when setting SPLIT_DB: FALSE

Case 3:

  • In mysql you can export each DB in it's own file when setting SPLIT_DB:TRUE
  • In pgsql you can export each DB in it's own file when setting SPLIT_DB:TRUE - and DB_NAME to the auth DB (*)

(*) In case of SPLIT_DB: FALSE or if POSTGRES_DB was manually set in the postgres image and is not equals to the user name POSTGRES_USER . When not specifying POSTGRES_DB then the value of POSTGRES_USER will be used.


My proposal is to introduce 3 backup options so that it works consistent:

  • [ ] Export single database
  • [ ] Export all DBs in single file
  • [ ] Export all DBs in multiple files

Alternatively we should add a segment to the README explaining the difference in functionality so that it is predictable.

jwillmer avatar Jun 09 '21 11:06 jwillmer

Makes sense as this image originally grew from an earlier set of images (mariadb, mongo, postgres -backup) and I merged them all together purely for ease of maintenance reasons.

Happy to take a PR on this, I am currently tied up for the next few months o n a big infrastructure migration and won't be able to commit time to changing functionality in spare time.

tiredofit avatar Jun 09 '21 16:06 tiredofit

I will see if I find time but I will need help testing the implementation. I can test pgsql since I already have it in use can you test mysql when I refactored it?

jwillmer avatar Jun 09 '21 20:06 jwillmer

Sure I can have my team test the MySQL/MariaDB section.

tiredofit avatar Jun 10 '21 13:06 tiredofit

@tiredofit pull request is created. Export all DBs in single file is only implemented (working) for mysql. The other two points are as described. Please let your guys test it and feel free to refactor the code. I believe it could be written in a more compact manner but I'm lacking the knowledge.

jwillmer avatar Jun 11 '21 22:06 jwillmer

I dont think you give yourself credit. Your work is just fine to be honest.

So I just want to go back up to Case 1 here - You stated that Mysql setting DB_NAME has no effect. It will operate without a database, but in actuality DB_NAME is how I have been using this image since inception. I'm going to think about all of this for a couple days as I believe there's another way that we can accomodate for this overall by pulling a list of databases live from the server (providing we have the right permissions, with MySQL I meant for the SPLIT_DB command to operate when DB_USER=root.

If what I am thinking is possible this could also open up some doors for multiple host backups which has been requested many times as well. Thanks for work so far.

tiredofit avatar Jun 12 '21 16:06 tiredofit

Any update on this?

sbrunecker avatar Dec 28 '21 15:12 sbrunecker

Multiple host backups now integrated into https://github.com/tiredofit/docker-db-backup/releases/tag/4.0.0

tiredofit avatar Nov 09 '23 03:11 tiredofit