Skip to content

Instantly share code, notes, and snippets.

@LogIN-
Created June 20, 2016 13:39
Show Gist options
  • Select an option

  • Save LogIN-/f6ac368d2438d8bb0768be856c069925 to your computer and use it in GitHub Desktop.

Select an option

Save LogIN-/f6ac368d2438d8bb0768be856c069925 to your computer and use it in GitHub Desktop.
Make ZFS backups with rsync because of some reason. Usually its not good idea but hey maybe comes useful..
#!/bin/bash
# Crontab Entry - use flock to prevent duplicate running
30 3 * * 1 /usr/bin/flock -xn /root/logs/rsync_lock -c /usr/local/bin/rsync_scripts/rsync.sh >/dev/null 2>&1
# Resume broken network connection.
while [ 1 ]
do
rsync --log-file=/root/logs/rsync.log --verbose --delete --force --checksum --inplace --no-whole-file --update --append --archive --compress-level=9 --skip-compress=gz/zip/z/rpm/deb/iso/bz2/t[gb]z/7z/mp[34]/mov/avi/ogg/jpg/jpeg/lzo/rzip/lzma/rar/ace --acls --xattrs --compress --partial --human-readable --one-file-system --timeout=999 --exclude-from=/.rsync-filter -e "ssh -T -o ConnectTimeout=999 -o ServerAliveInterval=340 -c arcfour" /tank/drives/xxxxx/ serverxxxxx:/tank/drives/xxxxx
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "rsync failure. Backing off and retrying..."
sleep 300
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment