From 4364ee3a312f6ca2258ea79e1c82d9148b18f1c6 Mon Sep 17 00:00:00 2001 From: Dominic Reich Date: Sat, 9 Mar 2024 12:27:14 +0100 Subject: [PATCH] Add webserver-backup this might be broken, the actual script doas not include weewx backups... --- webserver-backup.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 webserver-backup.sh diff --git a/webserver-backup.sh b/webserver-backup.sh new file mode 100644 index 0000000..f503ef3 --- /dev/null +++ b/webserver-backup.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# running on the rootserver that serves weewx and cloudlog for now +# running WeeWX and MariaDB +# will soon fetch and include webcam pics from ESP32-CAM +# Author: Dominic Reich +# License: MIT + +SQLDATE=$(date +%F-%R) + +WX_CONFIG=/home/weewx/weewx.conf +WX_SKINCONF=/home/weewx/skins/neowx-material/skin.conf + +CL_CONFIG=/var/www/sites/cloudlog/application/config/config.php +CL_DBCONF=/var/www/sites/cloudlog/application/config/database.php + +WX_OUTFILE=/tmp/weewx-backup-${SQLDATE}.sql +CL_OUTFILE=/tmp/cloudlog-backup-${SQLDATE}.sql + +DATE=$(date "+%A, %d. %B %Y") +CLOCK=$(date "+%H:%M") + +mysqldump -u weewx -p{password} weewx > ${WX_OUTFILE} +mysqldump -u cloudlog -p{password} cloudlog > ${CL_OUTFILE} +#echo testfile_weewx > ${WX_OUTFILE} +xz ${WX_OUTFILE} +xz ${CL_OUTFILE} + +echo '''Attached files are + + - Database backups + `'''${WX_OUTFILE}'''` + `'''${CL_OUTFILE}'''` + - WeeWX configuration file + `'''${WX_CONFIG}'''` + - neowx-material skin configuration file + `'''${WX_SKINCONF}'''` + - Cloudlog configuration files + `'''${CL_CONFIG}'''` + `'''${CL_DBCONF}'''` + +This mail was sent out on '''${DATE}''' at '''${CLOCK}'''. + +-- +Don'''\''''t ever think on replying to this mail address! +You'''\''''d be just ignored...''' | neomutt -s "Server backup from `date +\"%F %R\"`" \ + -a ${WX_OUTFILE}.xz ${WX_CONFIG} ${WX_SKINCONF} ${CL_OUTFILE}.xz ${CL_CONFIG} ${CL_DBCONF} -- {email} + +rm -f ${WX_OUTFILE}.xz ${CL_OUTFILE}.xz