nix-config/pkgs/drone-rsync/drone-rsync
Bruno BELANYI 9c80bc07b9 pkgs: add drone-rsync
A very simple wrapper script that I will migrate to, since 'drone-scp'
does not work for me anymore.
2022-06-20 14:34:37 +02:00

32 lines
700 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
ARGS=(
# Show readable progress in log
--verbose
--human-readable
--progress
# Have a one-to-one copy
--archive
--compress
--recursive
--delete
# Configure ssh client
--rsh "ssh -p ${SYNC_PORT:-22} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
)
eval "$(ssh-agent)"
SSHPASS="${SYNC_PASSPHRASE:-}" sshpass -P 'passphrase' -v -e ssh-add <(echo "${SYNC_KEY}")
if [ -n "${SYNC_DRY_RUN:-}" ]; then
ARGS+=(--dry-run)
fi
# shellcheck disable=2086
# FIXME: have a safer way to allow globbing the source
rsync \
"${ARGS[@]}" \
${SYNC_SOURCE} \
"${SYNC_USERNAME}@${SYNC_HOST}:${SYNC_TARGET}"