mirror-functions rsync mirror() function in bash, uses gawk, lockfile, sed, stat Features: - can be run from cron or by hand, - locking, - mirrors of several packages can be defined in one script, - possible a saparate frequency limit for each package in the script, - dry run (-n option) to show the actual rsync command, - force running only nth mirror() in the script (e.g. -f 5), does not override locking, - remembers when the recent mirroring of a package took place and if it was successful (using .files in ~ directory), - uses ~ directory for creating an rsync filter. - the mirroring can be completely blocked by creating ~/MIRROR_OFF file (its contents will be shown in mirrors logs). - minfree=1024 inside this file defines minimum free space the mirror will run with linux-debian sample rsync scripts; use -h option to see help linux-archlinux linux-centos rzm@sunsite3:/private/rzm/sunsite,1> /local/scripts/mirror/linux-debian -h /local/scripts/mirror/linux-debian [-h] [-f [NUM]] [-n] Script for mirroring rsync packages backed by mirror-functions library. -h this help -f [NUM] mirror even if the gap time set in the script have not passed. With NUM converns only package number NUM (conting from 1) -n dry run - do not execute rsync commans Syntax: # sourcing the function . /local/scripts/mirror/mirror-functions # before each call to the mirror() function one can set non-default # - rsync program path (rsync=…; default: rsync), # - options (options=…; default can be read from $defoptions variable), # - e-mail for error messages (email=…; default: `whoami`), # - time gap (gap=…; default: 2 [hours]) which limits frequency of mirroring - not sooner than gap after last successfull mirroring # At first mirroring attempt mirror() assumes that the previous one was 100000 hours ago. # example of "options" setting: options="-rtlvH --delete-after --delay-updates --safe-links --max-delete=1000 --timeout=3600" # official? + timeout # changing time gap (can be done before each mirror() call gap=24 #h # actual call: mirror SOURCE_RSYNC_URL DESTINATION_DIRECTORY [FILTER...] # the $p variable contains our default path to all packages defined in mirror-functions file but it does not have to be used mirror rsync://ftp5.gwdg.de/pub/linux/archlinux/ $p/linux-archlinux "- **~tmp~**" linux-debian.output output of the script mirrormail simple script to use with crontab which sets a subject of the e-mail # sample crontab entries: 51 */2 * * * /local/scripts/mirror/linux-debian 2>&1 | ~/bin/mirrormail linux-debian 0 * * * * echo | awk 'END { t=55*60*rand(); system("sleep "t) }'; /local/scripts/mirror/linux-archlinux 2>&1 | ~/bin/mirrormail linux-archlinux .