-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrun.sh
executable file
·39 lines (31 loc) · 980 Bytes
/
run.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
#!/bin/bash
echo "Preparing..."
aws --version
# Reading config
KEY=`jq -r .aws_key_id /data/options.json`
SECRET=`jq -r .aws_key_secret /data/options.json`
BUCKET=`jq -r .bucket_name /data/options.json`
FOLDER=`jq -r .bucket_folder /data/options.json`
STORAGE_CLASS=`jq -r .storage_class /data/options.json`
DELETE=`jq -r .delete_if_missing /data/options.json`
ENDPOINT_URL=`jq -r .endpoint_url /data/options.json`
DEBUG=`jq -r .debug_mode /data/options.json`
# Setting up aws cli
aws configure set aws_access_key_id $KEY
aws configure set aws_secret_access_key $SECRET
# Prepare sync command
SOURCE="/backup/"
DESTINATION="s3://$BUCKET/$FOLDER"
OPTIONS="--storage-class $STORAGE_CLASS"
if [[ $DELETE == true ]]; then
OPTIONS+=" --delete"
fi
if [[ -n "$ENDPOINT_URL" ]]; then
OPTIONS+=" --endpoint-url $ENDPOINT_URL"
fi
if [[ $DEBUG == true ]]; then
OPTIONS+=" --debug"
fi
echo "Sync started..."
aws s3 sync $SOURCE $DESTINATION $OPTIONS
echo "Sync completed."