Skip to content

Commit 762e3ac

Browse files
committed
DB backup: fix rclone config access
1 parent 24129e9 commit 762e3ac

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

database-backup/scripts/other/lib/rclone.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,25 @@ fi
88

99
# Constants
1010
readonly RCLONE_CONCURRENCY=2
11+
readonly RCLONE_CONFIG_DIR=/etc/rclone
12+
readonly RCLONE_CONFIG_PATH="${RCLONE_CONFIG_DIR}/rclone.conf"
1113
readonly RCLONE_CHUNK_SIZE=16M
1214
readonly RCLONE_TIMEOUT=30s
1315

16+
rclone_cmd() {
17+
rclone --config="$RCLONE_CONFIG_PATH" $@
18+
}
19+
20+
#
21+
# === Setup ===
22+
#
23+
24+
rclone_bootstrap_config() {
25+
mkdir -p "$RCLONE_CONFIG_DIR"
26+
rclone_cmd config touch >/dev/null 2>&1
27+
chmod a+r $RCLONE_CONFIG_PATH
28+
}
29+
1430
#
1531
# === RDB Backup Functions ===
1632
#
@@ -20,7 +36,7 @@ readonly RCLONE_TIMEOUT=30s
2036
# - Target
2137
rclone_copy_url() {
2238
# Note: limit memory use by setting low concurrency & chunk size
23-
rclone copyurl "$1" "$2" \
39+
rclone_cmd copyurl "$1" "$2" \
2440
--low-level-retries 5 \
2541
--no-check-certificate \
2642
--progress \

database-backup/scripts/startup/50-env-configure-rclone.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
44
. "${SCRIPT_DIR}/../other/lib/_common.sh"
5+
. "${SCRIPT_DIR}/../other/lib/rclone.sh"
56

67
# Configure rclone tool with a set of S3 credentials
78
#
@@ -16,8 +17,11 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
1617
# Input validation
1718
require_env_vars S3_PROVIDER S3_ACCESS_KEY_ID S3_SECRET_ACCESS_KEY S3_REGION S3_ENDPOINT
1819

20+
echo "Configuring rclone remote…"
21+
1922
# Create configuration, will be used by later rclone invocations
20-
rclone config create s3-remote s3 \
23+
rclone_bootstrap_config
24+
rclone_cmd config create s3-remote s3 \
2125
provider "$S3_PROVIDER" \
2226
access_key_id "$S3_ACCESS_KEY_ID" \
2327
secret_access_key "$S3_SECRET_ACCESS_KEY" \

0 commit comments

Comments
 (0)