Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133401721
D25631.id75412.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D25631.id75412.diff
View Options
Index: share/man/man5/periodic.conf.5
===================================================================
--- share/man/man5/periodic.conf.5
+++ share/man/man5/periodic.conf.5
@@ -257,6 +257,18 @@
Set to
.Dq Li YES
to create backup of EFI System Partion (ESP).
+.It Va daily_backup_gmirror_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of gmirror information (i.e. output of `gmirror list`), see
+.Xr gmirror 8 .
+.It Va daily_backup_gmirror_verbose
+.Pq Vt bool
+Set to
+.Dq Li YES
+if you want the diff output between the new backup and the existing backup
+to be reported in your daily output.
.It Va daily_backup_gpart_enable
.Pq Vt bool
Set to
Index: usr.sbin/periodic/etc/daily/222.backup-gmirror
===================================================================
--- /dev/null
+++ usr.sbin/periodic/etc/daily/222.backup-gmirror
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# 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
Index: usr.sbin/periodic/etc/daily/Makefile
===================================================================
--- usr.sbin/periodic/etc/daily/Makefile
+++ usr.sbin/periodic/etc/daily/Makefile
@@ -11,6 +11,7 @@
200.backup-passwd \
210.backup-aliases \
221.backup-gpart \
+ 222.backup-gmirror \
330.news \
400.status-disks \
401.status-graid \
Index: usr.sbin/periodic/periodic.conf
===================================================================
--- usr.sbin/periodic/periodic.conf
+++ usr.sbin/periodic/periodic.conf
@@ -79,8 +79,12 @@
# 221.backup-gpart
daily_backup_gpart_enable="YES" # Backup partition table/boot partition/MBR
-daily_backup_gpart_verbose="NO" # Be verbose if new backup differs from the new one
+daily_backup_gpart_verbose="NO" # Be verbose if new backup differs from the old one
daily_backup_efi_enable="NO" # Backup EFI system partition (ESP)
+
+# 222.backup-gmirror
+daily_backup_gmirror_enable="NO" # Backup of gmirror info (i.e. output of `gmirror list`)
+daily_backup_gmirror_verbose="NO" # Log diff if new backup differs from the old one
# 300.calendar
daily_calendar_enable="NO" # Run calendar -a
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 26, 12:52 PM (8 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24230686
Default Alt Text
D25631.id75412.diff (3 KB)
Attached To
Mode
D25631: periodic script to create backup of gmirror information
Attached
Detach File
Event Timeline
Log In to Comment