You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

#!/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 <dominic{at}oe7drt.com>
# 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