Files
mirror_scripts/raspbian.sh
T
2022-06-08 22:13:06 +02:00

30 lines
563 B
Bash
Executable File

#!/bin/bash
logfile='/var/log/mirror/raspbian.log'
fatal() {
echo "$1"
echo -e "Last lines from log:\n"
tail $logfile
exit 1
}
home="/store"
target="${home}/mirror/raspbian"
lock='/tmp/raspbiansync.lck'
source='rsync://archive.raspbian.org/archive'
[ ! -d "${target}" ] && mkdir -p "${target}"
exec 9>"${lock}"
flock -n 9 || exit
rsync -rtlvHq --safe-links --delete-after --progress -h --timeout=600 --contimeout=60 -p \
--delay-updates --no-motd \
${source} \
"${target}" &>> $logfile || fatal "Failed to sync."
date >> $logfile