Skip to content

Instantly share code, notes, and snippets.

@AlekseySpiridonov
Created August 12, 2021 16:39
Show Gist options
  • Save AlekseySpiridonov/8c8ff6d98870782b78402863faa41ddc to your computer and use it in GitHub Desktop.
Save AlekseySpiridonov/8c8ff6d98870782b78402863faa41ddc to your computer and use it in GitHub Desktop.
MacOS rsync with retries every 120 seconds
#!/bin/bash
ADDITIONAL_KEYS=""
if [ ! -z "${3}" ]
then
ADDITIONAL_KEYS="${3}"
fi
echo "==============================="
echo "===== CUSTOM RSYNC SCRIPT ====="
echo "==============================="
echo 'Sync '$1' to '$2
echo "With params:""${ADDITIONAL_KEYS}"
echo "==============================="
while [ 1 ]
do
rsync -Pav --rsh ssh --partial --exclude="*.icloud" --exclude=".DS_Store" $ADDITIONAL_KEYS "${1}" "${2}"
if [ "$?" = "0" ] ; then
echo "==============================="
echo "====== C O M P L E T E D ======"
echo "==============================="
exit
else
echo "-------------------------------------------"
echo "Rsync failure. Backing off and retrying... "
echo "-------------------------------------------"
sleep 120
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment