-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paths3.sh
More file actions
executable file
·41 lines (27 loc) · 845 Bytes
/
s3.sh
File metadata and controls
executable file
·41 lines (27 loc) · 845 Bytes
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
#!/bin/bash
set -eu
source utils.sh
SCOPE_EXT="*.tar.gz"
DATA_PATH="backups/${SCOPE_EXT}"
S3_PATH="s3://${S3_BUCKET}/"
S3_REGION=${S3_REGION:-"eu-central-1"}
AWSCLI_FLAGS=${AWSCLI_FLAGS:-"--only-show-errors --no-progress"}
if [ -n "${ENDPOINT_URL}" ]; then
AWSCLI_FLAGS="${AWSCLI_FLAGS} --endpoint-url ${ENDPOINT_URL}"
fi
# Delete possible empty files before sync
find backups -type f -empty -delete
if ! test -n "$(find ./backups -maxdepth 1 -name "${SCOPE_EXT}" -print -quit)"
then
info "There are no backups to sync to S3, skipping."
exit 0
fi
SYNC="aws s3 sync backups ${S3_PATH} --region ${S3_REGION}"
# Sync backups to S3
if aws s3 sync backups ${S3_PATH} --region ${S3_REGION} ${AWSCLI_FLAGS};
then
rm -f backups/*
success "Backups were successfully synced to S3"
else
error "ERROR syncing backups to S3"
fi