build files for making podman containers
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.
 
 

41 lines
930 B

#!/bin/bash
# load environment variables
source /etc/environment
hour=$(date +%H)
day=$(date +%d)
month=$(date +%m)
year=$(date +%Y)
dumpdir=/vol/data
errlog=error/$year-$month-$day-T$hour.log
mkdir -p $dumpdir/error
cd $dumpdir
if [[ $# -lt 2 ]]; then
echo "Error: called with missing hour and/or day parameter. Script exited without running." | tee $errlog
exit 1
fi
if [[ $hour == $1 ]]; then
nc-occ maintenance:mode --on
fi
db-dump $DBNAME-hourly-$hour.sql 2>> $errlog
if [[ $hour == $1 ]]; then
nc-occ maintenance:mode --off
mv $DBNAME-hourly-$hour.sql $DBNAME-daily-$day.sql 2>> $errlog
if [[ $day == $2 ]]; then
mv $DBNAME-daily-$day.sql $DBNAME-$year-$month-$day.sql 2>> $errlog
fi
fi
# If error log is size 0, erase it because I don't like seeing it
if [[ ! -s $errlog ]]; then
rm $errlog
rmdir --ignore-fail-on-non-empty error
fi