|
|
@ -1,5 +1,11 @@ |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
rm_ife() { |
|
|
|
if [[ -e "$1" ]]; then |
|
|
|
rm -r "$1" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
# Check if server is started |
|
|
|
status=$(systemctl show mcbe -p ActiveState --value) |
|
|
|
if [[ $status != active ]]; then |
|
|
@ -18,21 +24,26 @@ cd /vol/data/backup |
|
|
|
|
|
|
|
# hourly backup |
|
|
|
mcbe-exec say "Autosaving..." |
|
|
|
if [[ -e worlds-hourly-$hour ]]; then |
|
|
|
rm -r worlds-hourly-$hour |
|
|
|
fi |
|
|
|
rm_ife worlds-hourly-$hour |
|
|
|
mcbe-backup worlds-hourly-$hour |
|
|
|
|
|
|
|
if [[ $hour -eq 1 ]]; then |
|
|
|
# 10#$var construction is to force base-10 interpretation of variable |
|
|
|
# because otherwise, numbers starting with 0 are interpreted as octal |
|
|
|
if [[ 10#$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 |
|
|
|
# should help deal with any memory leaks or other bugs |
|
|
|
players="" |
|
|
|
while [[ -z $players ]]; do |
|
|
|
players=$(mcbe-exec list | head -n 1 | cut -d ' ' -f 3 | cut -d '/' -f 1) |
|
|
|
done |
|
|
|
if [[ $players -eq 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/ |
|
|
|
rm_ife worlds-daily-$day |
|
|
|
mv worlds-hourly-$hour worlds-daily-$day |
|
|
|
if [[ 10#$day -eq 1 ]]; then |
|
|
|
mv worlds-daily-$day worlds-$year-$month-$day |
|
|
|
fi |
|
|
|
fi |
|
|
|