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.
37 lines
885 B
37 lines
885 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)
|
|
# check if any players are currently logged in
|
|
players=$(mcbe-exec list | cut -d ' ' -f 3 | cut -d '/' -f 1)
|
|
|
|
# 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
|
|
if [[ $players -eq 0 ]]; then
|
|
mcbe-shutdown
|
|
systemctl start mcbe
|
|
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
|
|
|