Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111565124
D25638.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D25638.diff
View Options
Index: head/share/man/man5/periodic.conf.5
===================================================================
--- head/share/man/man5/periodic.conf.5
+++ head/share/man/man5/periodic.conf.5
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 9, 2020
+.Dd November 6, 2020
.Dt PERIODIC.CONF 5
.Os
.Sh NAME
@@ -289,6 +289,57 @@
if you want the
.Pa /etc/mail/aliases
file backed up and modifications to be displayed in your daily output.
+.It Va daily_backup_zfs_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of the output generated from the
+.Xr zfs-list 8
+and
+.Xr zpool-list 8
+utilities.
+.It Va daily_backup_zfs_list_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zfs-list 8
+utility.
+The default is standard behavior.
+.It Va daily_backup_zpool_list_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zpool-list 8
+utility.
+The default is
+.Fl v .
+.It Va daily_backup_zfs_props_enable
+.Pq Vt bool
+Set to
+.Dq Li YES
+to create backup of the output generated from the
+.Xr zfs-get 8
+and
+.Xr zpool-get 8
+utilities.
+.It Va daily_backup_zfs_get_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zfs-get 8
+utility.
+The default is
+.Cm all .
+.It Va daily_backup_zpool_get_flags
+.Pq Vt str
+Set to the arguments for the
+.Xr zpool-get 8
+utility.
+The default is
+.Cm all .
+.It Va daily_backup_zfs_verbose
+.Pq Vt bool
+Set to
+.Dq Li YES
+to report a diff between the new backup and the existing backup
+in the daily output.
.It Va daily_calendar_enable
.Pq Vt bool
Set to
Index: head/usr.sbin/periodic/etc/daily/223.backup-zfs
===================================================================
--- head/usr.sbin/periodic/etc/daily/223.backup-zfs
+++ head/usr.sbin/periodic/etc/daily/223.backup-zfs
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# $FreeBSD$
+# Created by: Miroslav Lachman <000.fbsd@quip.cz>
+
+# Backup of zpool list, zfs list, zpool properties and zfs properties
+# for each filesystem. 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_zfs_verbose" in
+ [Yy][Ee][Ss]) show="YES"
+esac
+
+case "$daily_backup_zfs_enable" in
+ [Yy][Ee][Ss])
+
+ zpools=$(zpool list $daily_backup_zpool_list_flags)
+
+ if [ -z "$zpools" ]; then
+ echo 'daily_backup_zfs_enable is set to YES but no zpools found.'
+ rc=2
+ else
+ echo ""
+ echo "Backup of ZFS information for all imported pools";
+
+ echo "$zpools" > "$bak_dir/zpool_list.tmp"
+ rotate "zpool_list" $show
+
+ zfs list $daily_backup_zfs_list_flags > "$bak_dir/zfs_list.tmp"
+ rotate "zfs_list" $show
+ fi
+ ;;
+ *) rc=0;;
+esac
+
+case "$daily_backup_zfs_props_enable" in
+ [Yy][Ee][Ss])
+
+ zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp"
+ rotate "zfs_props"
+
+ zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp"
+ rotate "zpool_props"
+ ;;
+esac
+
+exit $rc
Index: head/usr.sbin/periodic/etc/daily/Makefile
===================================================================
--- head/usr.sbin/periodic/etc/daily/Makefile
+++ head/usr.sbin/periodic/etc/daily/Makefile
@@ -55,7 +55,8 @@
.endif
.if ${MK_ZFS} != "no"
-CONFS+= 404.status-zfs \
+CONFS+= 223.backup-zfs \
+ 404.status-zfs \
800.scrub-zfs
.endif
Index: head/usr.sbin/periodic/periodic.conf
===================================================================
--- head/usr.sbin/periodic/periodic.conf
+++ head/usr.sbin/periodic/periodic.conf
@@ -82,6 +82,15 @@
daily_backup_gpart_verbose="NO" # Be verbose if new backup differs from the new one
daily_backup_efi_enable="NO" # Backup EFI system partition (ESP)
+# 223.backup-zfs
+daily_backup_zfs_enable="NO" # Backup output from zpool/zfs list
+daily_backup_zfs_props_enable="NO" # Backup zpool/zfs filesystem properties
+daily_backup_zfs_get_flags="all" # flags passed to `zfs get`
+daily_backup_zfs_list_flags="" # flags passed to `zfs list`
+daily_backup_zpool_get_flags="all" # flags passed to `zpool get`
+daily_backup_zpool_list_flags="-v" # flags passed to `zpool list`
+daily_backup_zfs_verbose="NO" # Report diff between the old and new backups.
+
# 300.calendar
daily_calendar_enable="NO" # Run calendar -a
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 6, 8:22 AM (58 m, 46 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17011118
Default Alt Text
D25638.diff (4 KB)
Attached To
Mode
D25638: Add periodic script to backup zfs and zpool information
Attached
Detach File
Event Timeline
Log In to Comment