4 changed files with 78 additions and 17 deletions
@ -0,0 +1,42 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
if [[ -z $1 ]]; then |
||||
|
echo "Usage: $0 backup_dir" |
||||
|
exit 2 |
||||
|
fi |
||||
|
backup_dir="$1" |
||||
|
|
||||
|
# Check if directory exists |
||||
|
if [[ ! -d "$backup_dir" ]]; then |
||||
|
echo "Error: directory \"$backup_dir\" not found." |
||||
|
exit 1 |
||||
|
fi |
||||
|
cd "$backup_dir" |
||||
|
|
||||
|
# Check if server is active |
||||
|
status=$(systemctl show mcbe -p ActiveState --value) |
||||
|
# shutdown server if it is active |
||||
|
if [[ $status == active ]]; then |
||||
|
echo "Server is active: executing shutdown" |
||||
|
systemctl stop mcbe |
||||
|
sleep 1 |
||||
|
fi |
||||
|
|
||||
|
# remove current worlds |
||||
|
worlds_dir=/home/mcadmin/worlds |
||||
|
rm -r $worlds_dir/* |
||||
|
# copy backup to worlds_dir |
||||
|
rsync -aSH "$backup_dir/" "$worlds_dir/" |
||||
|
|
||||
|
# copy resources to each world in worlds_dir |
||||
|
resources_dir=/vol/data/resources |
||||
|
for d in "$worlds_dir/*"; do |
||||
|
rsync -aSH "$resources_dir/" "$d/" |
||||
|
done |
||||
|
|
||||
|
# start server back up if it was active |
||||
|
if [[ $status == active ]]; then |
||||
|
echo "Starting server back up..." |
||||
|
systemctl start mcbe |
||||
|
sleep 5 |
||||
|
fi |
Loading…
Reference in new issue