Last active
October 22, 2025 13:03
-
-
Save munshkr/f20e593efd361d45f6a085c5a980524a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # USAGE | |
| # ./rclone_copy_gcs_to_azure.sh <storage_account> <container> <gcs_path> <azure_path> [extra rclone args] | |
| # | |
| # Example: | |
| # ./rclone_copy_gcs_to_azure.sh mystorageaccount mycontainer \ | |
| # mybucket/path/to/images \ | |
| # path/to/images \ | |
| # --progress --transfers=32 | |
| STORAGE_ACCOUNT="${1:-}" | |
| CONTAINER="${2:-}" | |
| GCS_PATH="${3:-}" | |
| AZURE_PATH="${4:-}" | |
| shift 4 || true # allow passing extra args to rclone | |
| if [[ -z "$STORAGE_ACCOUNT" || -z "$CONTAINER" || -z "$GCS_PATH" || -z "$AZURE_PATH" ]]; then | |
| echo "Usage: $0 <storage_account> <container> <gcs_path> <azure_path> [extra rclone args]" >&2 | |
| exit 1 | |
| fi | |
| KEY=$(az storage account keys list -n "$STORAGE_ACCOUNT" --query "[0].value" -o tsv 2>/dev/null) | |
| if [[ -z "$KEY" ]]; then | |
| echo "Failed to fetch key for storage account '$STORAGE_ACCOUNT'." >&2 | |
| exit 1 | |
| fi | |
| AZURE_REMOTE=":azureblob,account=${STORAGE_ACCOUNT},key=${KEY}:${CONTAINER}/${AZURE_PATH}" | |
| rclone copy \ | |
| "gcs:${GCS_PATH}" \ | |
| "$AZURE_REMOTE" \ | |
| --fast-list \ | |
| --checkers=16 \ | |
| --transfers=32 \ | |
| --progress \ | |
| "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment