Created
June 5, 2023 01:42
-
-
Save iambryancs/8521dfa859be939c91d3e21c42ed256d to your computer and use it in GitHub Desktop.
Kubernetes rsync wrapper
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
#!/bin/bash | |
# Source: https://serverfault.com/a/887402/169782 | |
# Usage: | |
# krsync -av --progress --stats src-dir/ pod<@namespace>:/dest-dir | |
if [ -z "$KRSYNC_STARTED" ]; then | |
export KRSYNC_STARTED=true | |
exec rsync --blocking-io --rsh "$0" $@ | |
fi | |
# Running as --rsh | |
namespace='' | |
pod=$1 | |
shift | |
# If user uses pod@namespace, rsync passes args as: {us} -l pod namespace ... | |
if [ "X$pod" = "X-l" ]; then | |
pod=$1 | |
shift | |
namespace="-n $1" | |
shift | |
fi | |
exec kubectl $namespace exec -i $pod -- "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment