| Server IP : 82.208.35.60 / Your IP : 216.73.216.89 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /etc/periodic/daily/ |
Upload File : |
#!/bin/sh
# $FreeBSD: releng/12.4/usr.sbin/periodic/etc/daily/222.backup-gmirror 368514 2020-12-10 13:25:45Z gbe $
# Created by: Miroslav Lachman <000.fbsd@quip.cz>
# Backup output from `gmirror list`, which provides detailed information
# of all gmirrors. The backup will be stored in /var/backups/.
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi
bak_dir=/var/backups
rotate() {
base_name=$1
show_diff=$2
file="$bak_dir/$base_name"
if [ -f "${file}.bak" ]; then
rc=0
if cmp -s "${file}.bak" "${file}.tmp"; then
rm "${file}.tmp"
else
rc=1
[ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
else
rc=1
mv "${file}.tmp" "${file}.bak" || rc=3
[ -n "$show_diff" ] && cat "${file}.bak"
fi
}
case "$daily_backup_gmirror_verbose" in
[Yy][Ee][Ss]) show="YES"
esac
case "$daily_backup_gmirror_enable" in
[Yy][Ee][Ss])
gmirrors=$(gmirror status 2> /dev/null | \
awk '$1 ~ /^mirror\// { sub(/mirror\//, ""); print $1 }')
if [ -z "$gmirrors" ]; then
echo ""
echo "daily_backup_gmirror_enable is set to YES but no gmirrors found."
rc=2
else
echo ""
echo "Backup of gmirror information for:";
for m in ${gmirrors}; do
echo "$m"
safe_name=$(echo "gmirror.${m}" | tr -cs ".[:alnum:]\n" "_")
if ! gmirror status -s "${m}" | grep -F -v "COMPLETE"; then
gmirror list "${m}" > "$bak_dir/$safe_name.tmp"
rotate "$safe_name" $show
fi
done
fi
;;
*) rc=0;;
esac
exit $rc