Last active
June 10, 2022 18:31
-
-
Save tassaron/75bf173e644c8e858cfce3644e2e1679 to your computer and use it in GitHub Desktop.
SSH copy and unzip the latest Bedrock Dedicated Server backup created by TapeWerm's MCscripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install unzip. Put your IP on next line. Voila! | |
IP= | |
PORT=22 | |
BACKUP_DIR=~/MCbackups | |
time="$1" | |
if [ -z "$1" ]; then | |
time=04-05 | |
fi | |
if [ -z $IP ]; then | |
echo "Edit server ip into $0" | |
exit | |
fi | |
ls "$BACKUP_DIR" > /dev/null 2>&1 | |
if [ $? != 0 ]; then | |
mkdir "$BACKUP_DIR" | |
if [ $? != 0 ]; then | |
echo "Couldnt create $BACKUP_DIR" | |
exit | |
fi | |
fi | |
abort_if_failed() { | |
if [ $? != 0 ]; then | |
echo "Previous command failed. Aborting" | |
exit | |
fi | |
} | |
year=$(date +"%Y") | |
month=$(date +"%m") | |
day=$(date +"%d") | |
scp -P $PORT -r $IP:/opt/MC/bedrock_backups/MCBE/FriendWorld/$year/$month/"$day"_"$time".zip /tmp/. | |
abort_if_failed | |
dir="$BACKUP_DIR"/$(date +"%Y-%m-%d") | |
newdir="$dir" | |
iter=0 | |
ls "$dir" > /dev/null 2>&1 | |
while [ $? == 0 ]; do | |
let iter=$iter+1 | |
newdir="$dir"-$iter | |
ls "$newdir" > /dev/null 2>&1 | |
done | |
mkdir "$newdir" | |
abort_if_failed | |
unzip /tmp/"$day"_"$time".zip -d "$newdir"/$year-$month-$day/ | |
abort_if_failed | |
rm /tmp/"$day"_"$time".zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment