Files
sqlite-backup-s3/scripts/minio_uploader.sh
T
vasyansk 5646ecd6dd
docker-build / Build image (push) Failing after 6s
fix cron after first run + add hc
2026-09-01 11:00:36 +07:00

46 lines
960 B
Bash

#!/bin/bash
set -u
# Create rclone config on-the-fly in a writable location
RCLONE_CONFIG_DIR="/tmp/rclone"
mkdir -p "$RCLONE_CONFIG_DIR"
export RCLONE_CONFIG="$RCLONE_CONFIG_DIR/rclone.conf"
cat > "$RCLONE_CONFIG" << EOF
[myminio]
type = s3
provider = Minio
access_key_id = $MINIO_ACCOUNT_ID
secret_access_key = $MINIO_APPLICATION_KEY
endpoint = $MINIO_ENDPOINT
region = $MINIO_LOCATION
acl = private
no_check_bucket = true
EOF
chmod 600 "$RCLONE_CONFIG"
# All commands take full remote paths; callers own the path building.
case "${1:-}" in
copy)
echo "copy from $2 to $3"
rclone copy --stats-one-line --retries 3 "$2" "$3"
;;
list)
echo "list $2" >&2
rclone ls "$2"
;;
size)
# bytes of a single remote object, empty output if it does not exist
rclone lsf --format s "$2" 2>/dev/null
;;
delete)
echo "delete $2"
rclone deletefile "$2"
;;
*)
echo "usage: $0 {copy SRC DST|list PATH|size FILE|delete FILE}" >&2
exit 2
;;
esac