Skip to content

Instantly share code, notes, and snippets.

@joshespi
Last active August 11, 2023 16:23
Show Gist options
  • Save joshespi/b829c527b5f915c80dfa2330ae480b0f to your computer and use it in GitHub Desktop.
Save joshespi/b829c527b5f915c80dfa2330ae480b0f to your computer and use it in GitHub Desktop.
pcsd - pi device, ship backup folder to backup server.
#!/bin/bash
hs=$HOSTNAME
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=10
i=0
# Set the initial return value to failure
false
while [ $? -ne 0 -a $i -lt $MAX_RETRIES ]
do
i=$(($i+1))
#scp -r -l 5000 /home/pi/backup/ tech@158.91.6.55:/home/tech/piBackups/"$hs"/
rsync -avz --partial --progress /home/pi/backup/ tech@158.91.6.55:/home/tech/piBackups/"$hs"/
done
if [ $i -eq $MAX_RETRIES ]
then
logger "Hit maximum number of retries, ending."
fi
@joshespi
Copy link
Author

switched to rsync to help stop creating sub folders of subsequent backups at destination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment