fradelg / docker-mysql-cron-backup

Docker image to backup all your databases periodically
Apache License 2.0
295 stars 111 forks source link

Make backup on container shutdown #90

Closed g-nardiello closed 1 year ago

g-nardiello commented 1 year ago

How is possible to automatically make a backup when I'm shutdown the container?

I use automatic backup with cron and automatic restore on startup. If I restart the container, it restores the last backup and I lose all modifications made after that.

Could you help me? Thanks

fradelg commented 1 year ago

Hi,

In you case, you should just remove the INIT_RESTORE_LATEST variable in the container environment.

Actually, I wouldn't recommend to use this option as it is better to restore the backups when you start from scratch and that can be done running the container once without the CRON task.

If you still want to go that path, I would recommend you to check the bash trap command

Regards

g-nardiello commented 1 year ago

Hi,

Thank you very much! I need an integrated solution, so I'll develop trap as you suggest. I could to add a TRAP with SIGHUP SIGINT SIGTERM to start a last backup before closing. If you wish, I could pull that feature with a flag when is completed!

Regards

fradelg commented 1 year ago

Awesome. Yes, please submit your PR when you think is ready and it works for your use case.

Thanks!

g-nardiello commented 1 year ago

Hi, I completed my work on that feature and it works on my environment. I created PR for the feature.

I created also PR for bugs I found on my working environment, and for other useful features I implemented!

fradelg commented 1 year ago

That's really impressive! Thank you so much!

I made a few minor comments to some of the PRs and merge others. I will review them as soon as I can.

g-nardiello commented 1 year ago

Thank you! I replied, I will also watch again as soon I can.

g-nardiello commented 1 year ago

Hi, I think this is solved.

Could you also release a new tagged version and tagged docker image with the last features, please?

fradelg commented 1 year ago

Done! Can you close this issue when you feel it is really solved?

g-nardiello commented 1 year ago

Great, thanks!