Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New schemas not backed up #214

Open
bansalvinay opened this issue Jan 22, 2023 · 3 comments
Open

New schemas not backed up #214

bansalvinay opened this issue Jan 22, 2023 · 3 comments

Comments

@bansalvinay
Copy link

I'm using Ubuntu Mysql image.
The backup runs fine for the databases which are created before this container is started. It runs for these databases continuously on cron as expected. But when there are new databases created, these are not backed up until this container is restarted.

Here's my composer code for mysql-backup :

db-backup:
    image: databack/mysql-backup:latest
    restart: 'always'
    container_name: 'smartsites-db-backup'
    depends_on: 
      - database
    volumes:
      - ${DB_BACKUP_DIR}:/db
      - ${DB_BACKUP_TEMP_DIR}:/tmp
    user: root
    environment:
      DB_SERVER: database
      DB_PORT: 3306
      DB_USER: root
      COMPRESSION: gzip
      DB_DUMP_BY_SCHEMA: "true"
      DB_PASS: ${MYSQL_ROOT_PASSWORD}
      DB_DUMP_CRON: "* * * * *"
      DB_DUMP_DEBUG: "true"
      DB_DUMP_TARGET: /db
@deitch
Copy link
Collaborator

deitch commented Jan 23, 2023

I recommend running it with DB_DUMP_DEBUG=true and then putting output here (please scrub sensitive data first). However, I strongly suspect it is because DB_NAMES is a global var and is set here, and so it is preset the next loop. It should be a simple fix. Care to open a PR for it?

@pcrt
Copy link
Contributor

pcrt commented Mar 14, 2023

That's right, the problem is relative to the global var DB_NAMES which is not reset if already set previously. This also causes an error in the execution if the DB_DUMP_BY_SCHEMA flag is set and one or more databases are deleted after the first run of the script, because it continue to backup a schema that previously removed .

I think the simple way to do that fix is to remove the control between these line here, in that way the script reload the list every time is running .

Maybe one day i can make highlight line selection more precise when github decide to implement this feature 😆

If you want, I can do the PR.

@deitch
Copy link
Collaborator

deitch commented Mar 15, 2023

I think the simple way to do that fix is to remove the control between these line here, in that way the script reload the list every time is running

Well, almost. If the user explicitly passed DB_NAMES, then it restricts it to those, so it will require a little reworking to capture command-line-passed and only check each time if that was not passed.

I would appreciate the PR, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants