28 lines
601 B
Bash
Executable File
28 lines
601 B
Bash
Executable File
#!/bin/bash
|
|
|
|
sleep_secs=120
|
|
|
|
do_backup() {
|
|
for hostlogin in $(cat hostlist); do
|
|
host=$(echo $hostlogin | cut "-d@" -f2)
|
|
echo $host
|
|
target=backups/$host/$(date --iso-8601=seconds)
|
|
mkdir -p $target
|
|
rsync --archive --verbose --prune-empty-dirs --exclude ".*" --exclude "/snap" --exclude "Screenshot from *" --max-size 200K $hostlogin:/home/contestant/ $target
|
|
chmod o+rx $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
|