-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeebackup.sh
More file actions
151 lines (118 loc) · 3.83 KB
/
geebackup.sh
File metadata and controls
151 lines (118 loc) · 3.83 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#######################################################
## Google Earth Enterprise Backup Script
## Created by Dale Kunce: (dale@normalhabit.com)
##
## Started with advice from Google Support Page @
## http://bit.ly/ryOQ2f
#######################################################
#gehttpd dir
ghttpdir=/opt/google/gehttpd/
#stuff to backup
gassets=/gevol/assets/
gprojects=Projects/Vector/
gkmls=/volumes/kml
gicons=/gevol/src/icons/
#backup dirs
gbu=/data/backup/
gbuassets=/data/backup/assets/
gbulayers=/data/backup/layertemplates/
gbukmls=/data/backup/kmls/
gbuicons=/data/backup/icons/
#tars of backups
gtar=/data/zips/
#logs
glog=/data/logs/gBackupLog.txt
gXMLlist=/data/logs/gXML.txt
gKMLlist=/data/logs/gKML.txt
gIconlist=/data/logs/gIcon.txt
#######################################################
## Do Not Edit Below this line
#######################################################
echo "BACKUP $(date +%Y_%m_%d)" >> $glog
#backup gehttpd
echo "starting gehttpd backup"
cd $ghttpdir
rsync -r -l htdocs cgi-bin conf conf.d $ghttpdir
if [ $? == 0 ]; then
echo "success gehttpd $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED gehttpd $(date +%Y_%m_%d)" >> $glog
fi
#backup config and userdata stuff in assets
echo "starting assets backup"
cd $gassets
rsync -r .config .userdata $gbuassets
if [ $? == 0 ]; then
echo "success assets $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED assets $(date +%Y_%m_%d)" >> $glog
fi
#backup the ever important xml
echo "starting xml backup"
find . -name \*xml > $gXMLlist
rsync --files-from=$gXMLlist $gassets $gbuassets
echo "gooFileList updated $(date +%Y%m%d)" >> $gXMLlist
if [ $? == 0 ]; then
echo "success xml $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED xml $(date +%Y_%m_%d)" >> $glog
fi
#backup kml directory
echo "starting kml backup"
cd $gkmls
find . -name \*kml > $gKMLlist
find . -name \*kmz >> $gKMLlist
rsync -r -l --files-from=$gKMLlist $gkmls $gbukmls
echo "KML file list updated $(date +%Y_%m_%d)" >> $gKMLlist
if [ $? == 0 ]; then
echo "success kml $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED kml $(date +%Y_%m_%d)" >> $glog
fi
#backup icons
echo "starting icon backup"
cd $gicons
find . -name \*png > $gIconlist
rsync -r -l --files-from=$gIconlist $gicons $gbuicons
echo "Icon File List Updated $(date +%Y_%m_%d)" >> $gIconlist
if [ $? == 0 ]; then
echo "success icons $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED icons $(date +%Y_%m_%d)" >> $glog
fi
#backup vector layer templates
echo "starting layer template backup"
#delete layer template dir otherwise fusion throws an error
rm -rf $gbulayers
if [ $? == 0 ]; then
echo "success cleaned $gbulayers $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED cleaned $gbulayers $(date +%Y_%m_%d)" >> $glog
fi
#add multiple projects by adding a new line for each project
#geeexportlayertemplate --project [relative path to project] --alllayers -o [absolute path to backup location (must be unique for each project)]
geexportlayertemplate --project $gprojects --alllayers -o $gbulayers
if [ $? == 0 ]; then
echo "success layer templates $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED layer templates $(date +%Y_%m_%d)" >> $glog
fi
#create archives of layer templates and other stuff
#to save space clean up the backup dir of tar files older than seven days
echo "starting tar"
cd $gtar
delfiles=`find -name \*tgz -mtime +7`
find -name \*tgz -mtime +7 -exec rm -f {} \;
if [ -z "$delfiles" ]; then
echo "No archives deleted $(date +%Y_%m_%d)" >> $glog
else
echo "DELETED $delfiles $(date +%Y_%m_%d)" >> $glog
fi
tar -Pczf $gtar/CTEarthBackup_$(date +%Y%m%d).tgz $gbu
if [ $? == 0 ]; then
echo "success archiving $(date +%Y_%m_%d)" >> $glog
else
echo "FAILED archiving $(date +%Y_%m_%d)" >> $glog
fi
exit