docker-db-backup
docker-db-backup copied to clipboard
Script is inconsistent for mysql and pgsql
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
settingDB_NAME
has no effect - In
pgsql
you need to setDB_NAME
to make the export work (*)
Case 2:
- In
mysql
you can export a file with all DBs when settingSPLIT_DB: FALSE
- In
pgsql
it will only export the DB set inDB_NAME
when settingSPLIT_DB: FALSE
Case 3:
- In
mysql
you can export each DB in it's own file when settingSPLIT_DB:TRUE
- In
pgsql
you can export each DB in it's own file when settingSPLIT_DB:TRUE
- andDB_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.
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.
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?
Sure I can have my team test the MySQL/MariaDB section.
@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.
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.
Any update on this?
Multiple host backups now integrated into https://github.com/tiredofit/docker-db-backup/releases/tag/4.0.0