File tree 3 files changed +52
-2
lines changed
3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,53 @@ countly_backup (){
147
147
countly_backupdb " $@ " ;
148
148
}
149
149
150
+ countly_save (){
151
+ if [ $# -eq 1 ]
152
+ then
153
+ echo " Please provide destination path" ;
154
+ return 0;
155
+ fi
156
+
157
+ if [ $# -lt 2 ]
158
+ then
159
+ echo " Please provide file paths" ;
160
+ return 0;
161
+ fi
162
+
163
+ if [ ! -d $2 ]
164
+ then
165
+ mkdir -p $2
166
+ fi
167
+
168
+ if [ -f $1 ]
169
+ then
170
+ match=false
171
+ files=$( ls $2 | wc -l)
172
+
173
+ if [ $files -gt 0 ]
174
+ then
175
+ for d in $2 /* ; do
176
+ diff=$( diff $1 $d | wc -l)
177
+ if [ $diff == 0 ]
178
+ then
179
+ match=true
180
+ break
181
+ fi
182
+ done
183
+ fi
184
+
185
+ files=$(( files+ 1 ))
186
+ filebasename=$( basename $1 )
187
+ if [ " $match " == false ]
188
+ then
189
+ cp -a $1 $2 /${filebasename} .backup.${files}
190
+ fi
191
+
192
+ else
193
+ echo " The file does not exist"
194
+ fi
195
+ }
196
+
150
197
countly_restorefiles (){
151
198
if [ $# -eq 0 ]
152
199
then
280
327
echo " countly restorefiles path/to/backup # restores user/config files from provided backup" ;
281
328
echo " countly restoredb path/to/backup # restores countly db from provided backup" ;
282
329
echo " countly restore path/to/backup # restores countly db and config files from provided backup" ;
330
+ echo " countly save path/to/file /path/to/destination # copies the given file to the destination if no file with same data is present at the destination" ;
283
331
countly api ;
284
332
countly plugin ;
285
333
countly update ;
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ yum -y install nginx
51
51
set +e
52
52
useradd www-data
53
53
unalias cp
54
- cp /etc/nginx/conf.d/default.conf $DIR /config/nginx.default.backup
54
+ countly save /etc/nginx/conf.d/default.conf $DIR /config/nginx
55
+ countly save /etc/nginx/nginx.conf $DIR /config/nginx
55
56
cp $DIR /config/nginx.server.conf /etc/nginx/conf.d/default.conf
56
57
cp $DIR /config/nginx.conf /etc/nginx/nginx.conf
57
58
service nginx restart
Original file line number Diff line number Diff line change 75
75
fi
76
76
77
77
# configure and start nginx
78
- cp /etc/nginx/sites-enabled/default $DIR /config/nginx.default.backup
78
+ countly save /etc/nginx/sites-enabled/default $DIR /config/nginx
79
+ countly save /etc/nginx/nginx.conf $DIR /config/nginx
79
80
cp $DIR /config/nginx.server.conf /etc/nginx/sites-enabled/default
80
81
cp $DIR /config/nginx.conf /etc/nginx/nginx.conf
81
82
You can’t perform that action at this time.
0 commit comments