-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup
executable file
·61 lines (45 loc) · 1.57 KB
/
backup
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
#!/usr/bin/env bash
#Get the absolute path to the scriptfile
SCRIPTFILE=$0
#Example
#---------------------------------------------------------------
#ScriptFile: /Users/ivokrugers/Xamarin_Projects/TransTrack_iOS/test1
#---------------------------------------------------------------
#ProjectFolder: /Users/ivokrugers/Xamarin_Projects/TransTrack_iOS
#RootFolder: /Users/ivokrugers/Xamarin_Projects
#Folder: TransTrack_iOS
#---------------------------------------------------------------
#Get the absolute path to the containing folder
PROJECTFOLDER=${SCRIPTFILE%/*}
#Get the absolute path to the parent folder of the project folder
#ROOTFOLDER=${PROJECTFOLDER%/*}
#Get just the project folder name
FOLDERNAME=${PROJECTFOLDER##*/}
#Go to project folder
cd ${PROJECTFOLDER}
# Remove bin, obj and packages folders
./cleanup
# Got parent folder
cd ..
#Prepare the zip filename
PREFIX=$(date +'%Y-%m-%d')
ARCHIVE="${PREFIX} ${FOLDERNAME}.zip"
ITERATOR=1
#Get unique zip filename
while [ -f "./${ARCHIVE}" ]
do
ARCHIVE="${PREFIX}_$(printf "%02d" ${ITERATOR}) ${FOLDERNAME}.zip"
((ITERATOR++))
done
echo --[ZIP Folder]----------------------------------------------------------------------------
echo "$PROJECTFOLDER -> ${ARCHIVE}"
echo ------------------------------------------------------------------------------------------
# Create the zip archive
zip -r -db -q "${ARCHIVE}" ${FOLDERNAME}
echo "
To automatically close this terminal window go to Terminal app menu:
Terminal> Preferences> Profiles> Shell>
When the shell exits: -> Close if the shell exited cleanly
"
#Exit cleanly
exit 0