getmango / Mango

Mango is a self-hosted manga server and web reader
https://getmango.app
MIT License
1.7k stars 120 forks source link

[Feature Request] Automatic database backup #252

Closed DisableGraphics closed 1 year ago

DisableGraphics commented 2 years ago

Is your feature request related to a problem? Please describe. My database has corrupted 2 times already (Because I'm an idiot, not a problem with mango)

Describe the solution you'd like Mango could backup the database on start (or periodically) and copy it to a backup directory. If it detects a 500 server error, it deletes its database and then copies the latest backup (Or something similar)

Leeingnyo commented 2 years ago

Oh recently I had a similar issue :) I ran the mango with my hard disk detached, and my database was dumped with an empty database. I had to wait for 3 hours to scan completely... I backed up database separately after then :p

How about using crontab or other scheduled scripts/program for database backup? It's too diverse to cover various requirements. And I couldn't understand why a database would be restored when 500 error occurred. which 500 errors do you mean? please let me know :)

hkalexling commented 2 years ago

Yeah I agree with @Leeingnyo. The more unix approach is to have other software that excels at that (e.g., cron + rsync) to handle the backups. I would rather spend time working on/enhancing the core features. But of course, if someone is willing to work on this and submit a PR I will happily accept it :)

tr7zw commented 2 years ago

Could be cool to be a part of the docker image, and to handle it like how for example Minecraft handles saving using an "_old" file to which it reverts in case the jvm/server/host whatever died during the saving process. Basically: delete the backup, rename the file to be the new backup, save. When there is an issue on load, check the backup file if available. Only if both are gone/broken fall back to regenerating everything.

Edit: has the benefit that it only adds a few lines before saving, and a few lines in the loading logic.