-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweeklybackups.sh
executable file
·68 lines (51 loc) · 2.48 KB
/
weeklybackups.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Date: 07/02/2020
# Author: John
# This script copies the minecraft world folder to the map folder once a week, on Monday.
# Use the start.sh script to launch the backup process, as start.sh calls this script in a new screen.
# Every new folder copied over overwrites the latest world copy.
# The weekly backed up folder may be found publicly at https://github.com/MiddCraft/map
########################### USER INPUT #######################################
# NOTE: Make sure to add a trailing slash / at the end of folder names.
# Destination folder for weekly backups
weeklybackupsdir="/root/map/"
# Server source folder (where the world file to be backed-up is located)
# This is typically the folder which contains your Minecraft .jar and all other server files.
sourcedir="/root/MiddCraft/"
# Name of source world folder (typically called "world" by default), as well as nether & end folders
worlddirname="world"
netherdirname="world_nether"
enddirname="world_the_end"
# Commit message to be displayed on GitHub
commitmessage="Automated weekly map upload"
##############################################################################
# Source world folder path (where the Minecraft server files are located)
worlddir="${sourcedir}${worlddirname}/"
netherdir="${sourcedir}${netherdirname}/"
enddir="${sourcedir}${enddirname}/"
destworlddir="${weeklybackupsdir}${worlddirname}"
destnetherdir="${weeklybackupsdir}${netherdirname}"
destenddir="${weeklybackupsdir}${enddirname}"
echo "Starting up the weekly backup process..."
echo "The timezone used is UTC. Backups are saved to the $weeklybackupsdir folder every Monday."
import_backups () {
# Copy in the world folders to the destination directory
cp -r ${worlddir} ${netherdir} ${enddir} ${weeklybackupsdir}
cd ${destworlddir}
rm -r advancements/ playerdata/ stats/ # Remove any user data that should not be uploaded
}
while true; do
currentweekday="$(date +%A)"
if [ "$currentweekday" == "Monday" ]; then
# Removes user data from world files & copies the world backups over
import_backups
# This will not re-add files already existing or unmodified in
# git (e.g the README.md file), however it will delete any
# locally removed files
git commit -a -m "${commitmessage}"
git push
sleep 24h
fi
# Check every hour to see if it's Monday yet
sleep 1h
done