DB "canary" added - with fail/restart when connection dropped
[weathermon.git] / bin / dump-yesterday
1 #!/bin/sh
2
3 yesterday=`echo "print(os.date(\"%Y-%m-%d\",os.time()-24*60*60))" | /usr/bin/lua`
4
5 logdb=`uci get weathermon.process.logdb`
6
7 if [ -f "$logdb" ]; then
8
9   dumpdir=`uci get weathermon.process.archive_dir`/`echo "print(os.date(\"%Y/%m/%d\",os.time()-22*60*60))" | /usr/bin/lua`
10
11   mkdir -p $dumpdir
12
13   /usr/bin/weather-filter $logdb dump-compacted $yesterday $dumpdir
14
15   sqlite3 $logdb "delete from log where time_stamp<date('now','-2 day')"
16
17 fi