My script for Linux is (here) <https://raw.githubusercontent.com/vinceskahan/vds-weewx-backup-data/master/weewx-backup-copy.sh> if you want to see how I do it. A less cleaned up version has been in use here for something like 15 years if not longer. As the other folks said, copy your db to a scratch dir and work off the copy. At one point quite a few years ago this FAQ came up and several folks did checks for their backups being good and they were always fine.
On Friday, June 21, 2024 at 3:01:05 PM UTC-7 John Kline wrote: > > I don't know how I can make sure the database is not in the middle of a > transaction when I'm attempting the copy. > > Do a sha1sum of the database: > sha1sum /home/weewx/archive/weewx.sdb > Make the copy. > Do another sha1sum of the database: > sha1sum /home/weewx/archive/weewx.sdb > > If the sha1 hasn’t changed, you have a good copy. > If it has changed, sleep and try again. > > On Jun 21, 2024, at 2:14 PM, Jeff Allison <[email protected]> wrote: > > Cron job and copy of the copy sounds like a good plan. Thanks! > > > - Jeff > > On Friday, June 21, 2024 at 2:00:18 PM UTC-7 p q wrote: > >> I run a cron job at 2am that shuts down Weewx, copies the database and >> restarts it. I used to then copy the backup copy to google drive, but >> google made the authentication impossible, so I stopped doing that part. I >> just manually copy it from time to time - perhaps I should do what you're >> doing with pscp too. Anyway, copying the copy would protect you from a >> conflict. >> >> On Fri, Jun 21, 2024 at 1:48 PM Jeff Allison <[email protected]> wrote: >> >>> Hello, >>> >>> Just recently installed weewx and I'm looking for the best way to make >>> regular backups. My plan is to create a Windows batch file that uses pscp >>> to copy all the relevant files to a folder on my Windows system and >>> schedule that to run daily. Pretty straightforward, but I'm concerned about >>> getting a valid copy of the sqlite database file. The docs make this >>> warning: >>> >>> *For a SQLite configuration, do not make the copy of the database file >>> while in the middle of a transaction! Schedule the backup for immediately >>> after an archive record is written, and then make sure the backup completes >>> before the next archive record arrives. * >>> >>> I don't know how I can make sure the database is not in the middle of a >>> transaction when I'm attempting the copy. Shutting down and restarting >>> weewx I guess is possible using ssh commands in the batch file, but that's >>> getting more complicated. How worried do I need to be about getting a bad >>> backup file if I just copy the file over? >>> >>> Thanks! >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "weewx-user" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/weewx-user/a7ffec0e-81ac-453c-b113-1c497e36783dn%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/weewx-user/a7ffec0e-81ac-453c-b113-1c497e36783dn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Peter Quinn >> (415)794-2264 <(415)%20794-2264> >> > -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/f0f5983d-f11f-471e-9f46-bce458053fa2n%40googlegroups.com > > <https://groups.google.com/d/msgid/weewx-user/f0f5983d-f11f-471e-9f46-bce458053fa2n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/74f5d3ca-e52e-4e9b-a9dd-52237f5ced6fn%40googlegroups.com.
