You might find these shell script fragments helpful. If you call retry_backup_copy With arguments of the database to backup (weewx.sdb) and a destination file to backup to, the code will check to see if the cksum changed during the copy and also run an integrity check on the copy. If the cksum changed or the integrity check fails, the copy is retried. make_backup_copy() { db="$1" tmp_db_copy="$2" check_sum="`/usr/bin/cksum $db | cut -d ' ' -f 1`" cp "$db" $tmp_db_copy check_sum_after="`/usr/bin/cksum $db | cut -d ' ' -f 1`" if [ "$check_sum" != "$check_sum_after" ]; then echo "$db changed during cp!" return 1 fi integrity_check="`echo "pragma integrity_check;" | sqlite3 "$tmp_db_copy"`" if [ "$integrity_check" != "ok" ]; then echo "$tmp_db_copy failed integrity check!" return 2 fi return 0 } retry_backup_copy() { db="$1" tmp_db_copy="$2" retval=99 attempts=0 while [ "$retval" -ne 0 ]; do attempts="`/usr/bin/expr $attempts + 1`" if [ "$retval" -ne 99 ]; then echo "make_backup_copy attempt $attempts" fi make_backup_copy "$db" "$tmp_db_copy" retval="$?" done } On Mar 13, 2023, at 4:38 AM, michael.k...@gmx.at <michael.kainzba...@gmx.at> wrote: -- 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 weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/007A23DB-8E01-4FA4-9717-B052A3C95E63%40johnkline.com. |
- [weewx-user] Backing up weewx.sdb Jonathan Ryshpan
- [weewx-user] Re: Backing up weewx.sdb michael.k...@gmx.at
- Re: [weewx-user] Re: Backing up weewx... 'John Kline' via weewx-user