2021-03-05 15:24:30 +00:00
|
|
|
if screen -list | grep -q "MncftPublic"; then
|
|
|
|
publicBackup="true"
|
|
|
|
fi
|
|
|
|
if screen -list | grep -q "Minecraft"; then
|
|
|
|
otherBackup="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $publicBackup && -z $otherBackup ]] ; then
|
2021-03-26 23:52:56 +00:00
|
|
|
echo "Minecraft is not running. Exiting..."
|
|
|
|
exit 0
|
2020-05-06 15:20:39 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-27 00:18:30 +00:00
|
|
|
BACKUPDIR="/home/bruno/Backups/Minecraft-borg"
|
2020-05-21 19:07:38 +00:00
|
|
|
SERVERDIR="/home/bruno/Apps/Minecraft"
|
2021-03-05 15:24:30 +00:00
|
|
|
PUBLICDIR="$SERVERDIR/BedrockServer_Public_19132"
|
2020-05-21 19:07:38 +00:00
|
|
|
SURVIVALDIR="$SERVERDIR/BedrockServer_Survival_19132"
|
|
|
|
CREATIVEDIR="$SERVERDIR/BedrockServer_Creative_19134"
|
|
|
|
LogFile="log.txt"
|
2020-05-06 15:20:39 +00:00
|
|
|
|
2021-03-05 15:24:30 +00:00
|
|
|
BACKUPDATE=$(date +"%Y-%m-%d_%H-%M-%S")
|
|
|
|
|
2020-05-21 19:07:38 +00:00
|
|
|
alias run='screen -S Minecraft -X'
|
|
|
|
alias runSurvival='run at Survival stuff'
|
|
|
|
alias runCreative='run at Creative stuff'
|
2021-03-05 15:24:30 +00:00
|
|
|
alias runPublic='screen -S MncftPublic -X at Server stuff'
|
2020-05-21 19:07:38 +00:00
|
|
|
alias runAllWorlds='run at "#" stuff'
|
2020-05-06 15:20:39 +00:00
|
|
|
|
2020-05-21 19:07:38 +00:00
|
|
|
cd /home/bruno/Apps/Minecraft
|
2020-05-06 15:20:39 +00:00
|
|
|
|
2020-05-21 19:07:38 +00:00
|
|
|
runAllWorlds "^u"
|
2021-03-05 15:24:30 +00:00
|
|
|
# runAllWorlds "say $(date +%l:%M) - Saving worlds\n"
|
|
|
|
runPublic "say ^usave hold\n"
|
|
|
|
runAllWorlds "^usave hold\n"
|
2020-05-21 19:07:38 +00:00
|
|
|
sleep 2s
|
|
|
|
|
2021-03-05 15:24:30 +00:00
|
|
|
|
|
|
|
if [[ $publicBackup ]]; then
|
|
|
|
echo Preparing public
|
|
|
|
finishedPublic=""
|
|
|
|
timeout=30
|
|
|
|
while [[ $finishedPublic != *"Data saved."* ]]; do
|
|
|
|
if [[ $timeout -lt 1 ]]; then
|
|
|
|
notify-send "Error backuping Creative world"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
(( timeout-- ))
|
|
|
|
sleep 1s
|
|
|
|
runPublic "say ^usave query\n"
|
|
|
|
finishedPublic=$(tail -n 4 "$PUBLICDIR/$LogFile")
|
|
|
|
done
|
2021-03-27 00:18:30 +00:00
|
|
|
borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftPublic" "$PUBLICDIR"
|
2021-03-05 15:24:30 +00:00
|
|
|
runPublic "say ^usave resume\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $otherBackup ]]; then
|
|
|
|
echo Preparing others
|
|
|
|
finishedCreative=""
|
|
|
|
timeout=30
|
|
|
|
while [[ $finishedCreative != *"Data saved."* ]]; do
|
|
|
|
if [[ $timeout -lt 1 ]]; then
|
|
|
|
notify-send "Error backuping Creative world"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
(( timeout-- ))
|
|
|
|
sleep 1s
|
|
|
|
runCreative "^u"
|
|
|
|
runCreative "save query\n"
|
|
|
|
finishedCreative=$(tail -n 4 "$CREATIVEDIR/$LogFile")
|
|
|
|
done
|
2020-05-21 19:07:38 +00:00
|
|
|
runCreative "^u"
|
2021-03-05 15:24:30 +00:00
|
|
|
runCreative "save resume\n"
|
2020-05-21 19:07:38 +00:00
|
|
|
|
2021-03-05 15:24:30 +00:00
|
|
|
timeout=30
|
|
|
|
finishedSurvival=""
|
|
|
|
while [[ $finishedSurvival != *"Data saved."* ]]; do
|
|
|
|
if [[ $timeout -lt 1 ]]; then
|
|
|
|
notify-send "Error backuping Survival world"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
(( timeout-- ))
|
|
|
|
sleep 1s
|
|
|
|
runSurvival "^u"
|
|
|
|
runSurvival "save query\n"
|
|
|
|
finishedSurvival=$(tail -n 4 "$SURVIVALDIR/$LogFile")
|
|
|
|
done
|
|
|
|
|
2021-03-27 00:18:30 +00:00
|
|
|
borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftSurvival" "$SURVIVALDIR"
|
|
|
|
borg create --stats --compression auto,zstd,9 "$BACKUPDIR::$BACKUPDATE-MncftCreative" "$CREATIVEDIR"
|
2021-03-05 15:24:30 +00:00
|
|
|
runSurvival "^u"
|
|
|
|
runSurvival "save resume\n"
|
|
|
|
fi
|
2021-03-27 00:18:30 +00:00
|
|
|
borg prune --keep-within=3d --keep-hourly=96 --keep-weekly=8 --keep-monthly=6 "$BACKUPDIR"
|