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.
 
 

35 lines
832 B

#!/bin/bash
# Check if server is started
status=$(systemctl show mcbe -p ActiveState --value)
if [[ $status != active ]]; then
echo "mcbe.service is inactive. Exiting."
exit 1
fi
# get time
hour=$(date +%H)
day=$(date +%d)
month=$(date +%m)
year=$(date +%Y)
# cd to backup dir
cd /vol/data/backup
# hourly backup
mcbe-exec say "Autosaving..."
mcbe-backup worlds-hourly-$hour
if [[ $hour -eq 1 ]]; then
# if no players are present, restart the server
# should help deal with any memory leaks
players=$(mcbe-exec list | head -n 1 | cut -d ' ' -f 3 | cut -d '/' -f 1)
if [[ $players == "0" ]]; then
mcbe-restart
fi
# save daily and longterm backups
rsync -a worlds-hourly-$hour/ worlds-daily-$day/
if [[ $day -eq 1 ]]; then
rsync -a worlds-daily-$day/ worlds-$year-$month-$day/
fi
fi