Skip to content

Commit 499e5f6

Browse files
committed
Convert to using Google backend in rclone
1 parent e8180eb commit 499e5f6

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

app/zip2cloud

+1-12
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,18 @@ ZIP_BASE=backup_full_
2222
ZIP_NAME=${ZIP_BASE}${NOW}
2323

2424
[ -r /run/secrets/encryption_key ] || { echo "Encryption key not readable in /run/secrets/encryption_key" ; exit 1; }
25-
[ -r /run/secrets/s3_access_key ] || { echo "S3 access key not readable in /run/secrets/s3_access_key" ; exit 1; }
26-
[ -r /run/secrets/s3_secret_key ] || { echo "S3 secret key not readable in /run/secrets/s3_secret_key" ; exit 1; }
27-
[ -z "${S3_ENDPOINT}" ] && { echo "S3 endpoint not set in S3_ENDPOINT environment variable" ; exit 1; }
25+
[ -r /run/secrets/gcp_backup_creds ] || { echo "Google cloud service credentials not found in /run/secrets/gcp_back_creds" ; exit 1; }
2826
[ -z "${BUCKET}" ] && { echo "S3 bucketname not set in BUCKET environment variable" ; exit 1; }
2927
[ -z "${BUCKETPATH}" ] && { echo "Path within S3 bucket not set in BUCKETPATH environment variable" ; exit 1; }
3028
[ -z "${DELETE_DUMP}" ] || echo "DELETE_DUMP set, will delete files/directories under /dump/ when done compressing"
3129

3230
# This is the password used to generate the AES256 encryption key
3331
SECRET=`cat /run/secrets/encryption_key`
3432

35-
# Setup the S3 creds where rclone expects to find them in environment
36-
export AWS_ACCESS_KEY=`cat /run/secrets/s3_access_key`
37-
export AWS_SECRET_KEY=`cat /run/secrets/s3_secret_key`
38-
3933
# This is the Google Cloud Storage path, note that it depends on rclone being preconfigured
4034
# for "remote" using the runtime creds, check rclone config in /root/.config/rclone/rclone.conf
4135
REMOTE=remote:${BUCKET}/${BUCKETPATH}
4236

43-
echo "Updating rclone.conf with configuration"
44-
sed -i s/S3_ENDPOINT/${S3_ENDPOINT}/ /root/.config/rclone/rclone.conf || { echo "Could not set S3_ENDPOINT in /root/.config/rclone/rclone.conf" ; exit 1; }
45-
echo "Contents of rclone.conf - credentials are in AWS_ACCESS_KEY and AWS_SECRET_KEY"
46-
cat /root/.config/rclone/rclone.conf
47-
4837
# Delete any files older than 30 days in the zip directory
4938
echo "Deleting database archives older than 30 days"
5039
/usr/bin/find ${ZIP_DIR} -mtime +30 -type f -name "${ZIP_BASE}*" -print -exec rm {} \;

rclone.conf

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[remote]
2-
type = s3
3-
provider = Other
4-
env_auth = true
5-
endpoint = https://S3_ENDPOINT/
6-
acl = bucket-owner-full-control
2+
type = google cloud storage
3+
object_acl = projectPrivate
4+
bucket_acl = projectPrivate
5+
location = us-central1
6+
service_account_file = /run/secrets/gcp_backup_creds

0 commit comments

Comments
 (0)