-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackupscript.sh
More file actions
40 lines (31 loc) · 856 Bytes
/
Copy pathbackupscript.sh
File metadata and controls
40 lines (31 loc) · 856 Bytes
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
#!/bin/bash
# $1 is the world dir path
#Backup Region File Function
back_up_region_files()
{
CURRENTDATE=`date +"%Y-%m-%d"`
echo $CURRENTDATE "Backing Up Region Files...."
worldDirPath=$1
backupsDir="$worldDirPath/backups"
regionDir="$worldDirPath/region"
if [ ! -d $regionDir ]; then
echo "No region Dir Found"
return
fi
if [ ! -d $backupsDir ]; then
echo "Making backups Dir"
sudo mkdir $1backups
fi
zip -r -q $backupsDir/region_$CURRENTDATE.zip $regionDir
}
#Main Program
LASTUPDATEDATE=`date +"%Y-%m-%d"`
back_up_region_files $1
while [ true ]
do
CURRENTDATE=`date +"%Y-%m-%d"`
if [ "$CURRENTDATE" != "$LASTUPDATEDATE" ]; then
back_up_region_files $1
LASTUPDATEDATE=$CURRENTDATE
fi
done