EricZimmerman / VoronTools

Various scripts and tools
MIT License
218 stars 29 forks source link

proper way to backup the moonraker sqlite db in autocommit.sh #12

Open steeveone opened 3 weeks ago

steeveone commented 3 weeks ago

hello, installing sqlite3 and changing 2 lines of code you could implement a safer way to backup the moonraker sqlite db.

Steps: apt-get install sqlite3

add outfile=$config_folder/moonraker-sql.db variable in variable declarations substitute cp ~/printer_data/database/moonraker-sql.db ~/printer_data/config/ with sqlite3 $db_file ".backup $outfile"

you could also check for sqlite3 command existence and decide if do a hot backup or a copy of the archive...

EricZimmerman commented 3 weeks ago

Yea but then people need to do more stuff vs this which works fine? Have you run into issues with things the way they are?

steeveone commented 3 weeks ago

you are right, there is one more step involved. I did not have problems with the cp backup method, there is just the possibility of a corrupted db in case of concurrent access during a backup, so i tought it would be nice to have it properly done. said that it is up to you to modify the script or not.

easy way to implement both methods would be something like test -f $(which sqlite3) && sqlite3 $db_file ".backup $outfile || cp ~/printer_data/database/moonraker-sql.db" ~/printer_data/config/

`