#!/bin/bash sleep_secs=120 do_backup() { for host in $(cat hostlist); do echo $host target=backups/$host/$(date --iso-8601=seconds) mkdir -p $target rsync -e "ssh -F local.ssh_config" --recursive --links --perms --times --verbose --prune-empty-dirs --exclude ".*" --exclude "/snap" --exclude "Screenshot from *" --max-size 200K $host:/home/contestant/ $target done } if [ "$1" == timer ]; then while true; do do_backup echo echo "Finished, next backup in $sleep_secs seconds." echo echo sleep $sleep_secs done else do_backup fi