soios/contestops/backup-create.sh

26 lines
581 B
Bash
Raw Permalink Normal View History

2024-05-09 22:45:53 +02:00
#!/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