forked from carojkov/salesforce-export-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.sh
68 lines (52 loc) · 1.71 KB
/
upload.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
ruby salesforce-backup.rb
gdsfbackupfolderId='yourbasicfolderId'
yearfolderId
monthfolderId
backUpfolderName=$(date +"%Y-%b-%e")
echo $backUpfolderName
year=$(date +"%Y")
echo $year
month=$(date +"%b")
echo $month
checkYearFolderResult=`gdrive list -q "name='$year' and '$gdsfbackupfolderId' in parents" --no-header`
echo $checkYearFolderResult
# check year folder exists, if not, create
if [[ $checkYearFolderResult ]]; then
echo 'Year folder exists on Google Drive'
IFS='\ ' read -ra ADDR <<< "$checkYearFolderResult"
yearfolderId="${ADDR[0]}"
else
echo 'Year folder not exists, Created'
result=`gdrive mkdir -p $gdsfbackupfolderId $year`
IFS='\ ' read -ra ADDR <<< "$result"
yearfolderId="${ADDR[1]}"
fi
echo $yearfolderId
#check month folder under year folder
checkMonthFlderResult=`gdrive list -q "name='$month' and '$yearfolderId' in parents" --no-header`
# check year folder exists, if not, create
if [[ $checkMonthFlderResult ]]; then
echo 'Month folder exists on Google Drive'
IFS='\ ' read -ra ADDR <<< "$checkMonthFlderResult"
monthfolderId="${ADDR[0]}"
else
echo 'Month folder not exists, Created'
result=`gdrive mkdir -p $yearfolderId $month`
IFS='\ ' read -ra ADDR <<< "$result"
monthfolderId="${ADDR[1]}"
fi
echo $monthfolderId
#create backup file folder
createBackupFolderResult=`gdrive mkdir -p $monthfolderId $backUpfolderName`
IFS='\ ' read -ra ADDR <<< "$createBackupFolderResult"
backupFolderId="${ADDR[1]}"
echo $backupFolderId
echo 'Foldre Preparation finished!!! Start uploading...'
for f in ./archive/salesforce/*; do
gdrive upload -p $backupFolderId $f
done
echo 'Backup file upload finished!!'
echo 'Start clear local file'
rm -rf ./archive/salesforce/*
echo 'Clear finished!'