Created
July 9, 2018 09:00
-
-
Save hazcod/ac9dd6ea57712630082f186168c2b0b0 to your computer and use it in GitHub Desktop.
Load-balance rclone requests over multiple remotes.
This file contains 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 | |
rclone_from="/User/user/Downloads/" | |
rclone_to="/tmp/" | |
rclone_remotes=(remote1 remote2 remote3) | |
rclone_cmd="echo" | |
rclone_opt="--verbose" | |
index_file="/tmp/rclone.index" | |
index_curr=0 | |
if [ -f "$index_file" ]; then | |
index_curr=$(cat "$index_file") | |
fi | |
if ((index_curr >= ${#rclone_remotes[@]} -1)); then | |
index_curr=0 | |
else | |
index_curr=$((index_curr + 1)) | |
fi | |
echo "$index_curr" > "$index_file" | |
remote="${rclone_remotes[$index_curr]}" | |
echo "Using remote: $remote" | |
"$rclone_cmd" "$rclone_opt" "$rclone_from" "${remote}:${rclone_to}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment