From e0331f4f2e5bf250701e244a07ea30dc49d5b967 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Wed, 22 Oct 2008 20:15:55 +0000 Subject: [PATCH] Add a periodic(8) script to run 'hammer cleanup' (snapshot, prune and reblock all HAMMER filesystems) on a nightly basis. The exact behavior (period, retention and run time) can be configured by tweaking /snapshots/config as described in hammer(5). --- etc/defaults/periodic.conf | 6 ++++- etc/periodic/daily/160.clean-hammer | 32 ++++++++++++++++++++++++++ etc/periodic/daily/Makefile | 3 ++- sbin/hammer/hammer.8 | 23 +++++++++---------- share/man/man5/hammer.5 | 35 +++++++++-------------------- share/man/man5/periodic.conf.5 | 16 +++++++++++-- 6 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 etc/periodic/daily/160.clean-hammer diff --git a/etc/defaults/periodic.conf b/etc/defaults/periodic.conf index 115a7d08b4..882b422c7e 100644 --- a/etc/defaults/periodic.conf +++ b/etc/defaults/periodic.conf @@ -14,7 +14,7 @@ # refer to the periodic.conf(5) manual page. # # $FreeBSD: src/etc/defaults/periodic.conf,v 1.7.2.13 2002/11/07 19:43:16 thomas Exp $ -# $DragonFly: src/etc/defaults/periodic.conf,v 1.7 2007/12/29 21:44:44 matthias Exp $ +# $DragonFly: src/etc/defaults/periodic.conf,v 1.8 2008/10/22 20:15:55 swildner Exp $ # # What files override these defaults ? @@ -68,6 +68,10 @@ daily_clean_rwho_verbose="YES" # Mention files deleted # 150.clean-hoststat daily_clean_hoststat_enable="YES" # Delete .hoststat daily +# 160.clean-hammer +daily_clean_hammer_enable="YES" # HAMMER maintenance +daily_clean_hammer_verbose="NO" # Be verbose + # 200.backup-passwd daily_backup_passwd_enable="YES" # Backup passwd & group diff --git a/etc/periodic/daily/160.clean-hammer b/etc/periodic/daily/160.clean-hammer new file mode 100644 index 0000000000..d3a52d27fe --- /dev/null +++ b/etc/periodic/daily/160.clean-hammer @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $DragonFly: src/etc/periodic/daily/160.clean-hammer,v 1.1 2008/10/22 20:15:55 swildner Exp $ +# +# Snapshot/prune/reblock all HAMMER file systems +# + +# 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 + +case "$daily_clean_hammer_enable" in + [Yy][Ee][Ss]) + echo "" + echo "HAMMER maintenance:" + case "$daily_clean_hammer_verbose" in + [Yy][Ee][Ss]) + verbose=-v;; + *) + verbose=;; + esac + + hammer $verbose cleanup && rc=0;; + + *) rc=0;; +esac + +exit $rc diff --git a/etc/periodic/daily/Makefile b/etc/periodic/daily/Makefile index 4f6bd76e52..4c603916ee 100644 --- a/etc/periodic/daily/Makefile +++ b/etc/periodic/daily/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/etc/periodic/daily/Makefile,v 1.4.2.4 2002/07/18 12:36:07 ru Exp $ -# $DragonFly: src/etc/periodic/daily/Makefile,v 1.3 2003/06/17 05:15:01 dillon Exp $ +# $DragonFly: src/etc/periodic/daily/Makefile,v 1.4 2008/10/22 20:15:55 swildner Exp $ FILES= 100.clean-disks \ 110.clean-tmps \ @@ -7,6 +7,7 @@ FILES= 100.clean-disks \ 130.clean-msgs \ 140.clean-rwho \ 150.clean-hoststat \ + 160.clean-hammer \ 200.backup-passwd \ 210.backup-aliases \ 220.backup-distfile \ diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8 index 6a51e2d778..cd267dd4f5 100644 --- a/sbin/hammer/hammer.8 +++ b/sbin/hammer/hammer.8 @@ -30,8 +30,9 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.55 2008/10/08 21:01:54 thomas Exp $ -.Dd October 8, 2008 +.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.56 2008/10/22 20:15:55 swildner Exp $ +.\" +.Dd October 22, 2008 .Dt HAMMER 8 .Os .Sh NAME @@ -231,19 +232,16 @@ A snapshots period of 0 disables snapshot generation and prunes using if no snapshots exists. A prune max-runtime of 0 means unlimited. .Pp -If period hasn't passed since previous +If period hasn't passed since the previous .Ar cleanup run nothing is done. For example a day has passed when midnight is passed (localtime). -It is recommended to run -.Ar cleanup -once a day, depending on the configured period, from a -.Xr cron 8 -job. -For example: -.Bd -literal -offset indent -15 2 * * * hammer cleanup >>/var/log/hammer.log 2>&1 -.Ed +By default, +.Dx +is set up to run +.Nm Ar cleanup +nightly via +.Xr periodic 8 . .Pp The default configuration file will create a daily snapshot, do a daily pruning and reblocking run and a monthly recopy run. @@ -713,6 +711,7 @@ recommended slave PFS snapshots directory .Sh SEE ALSO .Xr undo 1 , .Xr HAMMER 5 , +.Xr periodic.conf 5 , .Xr mount_hammer 8 , .Xr mount_null 8 , .Xr newfs_hammer 8 diff --git a/share/man/man5/hammer.5 b/share/man/man5/hammer.5 index 1c42e84858..e8b465b1ce 100644 --- a/share/man/man5/hammer.5 +++ b/share/man/man5/hammer.5 @@ -29,9 +29,9 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/share/man/man5/hammer.5,v 1.13 2008/10/07 22:23:12 thomas Exp $ +.\" $DragonFly: src/share/man/man5/hammer.5,v 1.14 2008/10/22 20:15:55 swildner Exp $ .\" -.Dd September 28, 2008 +.Dd October 22, 2008 .Os .Dt HAMMER 5 .Sh NAME @@ -271,20 +271,18 @@ mount_hammer /dev/ad0s1d /dev/ad1s1d /home .Pp Once created and mounted, .Nm -file systems need periodic clean-up making snapshots, pruning and reblocking, +file systems need periodic clean up making snapshots, pruning and reblocking, in order to have access to history and file system not to fill up. For this it is recommended to use the .Xr hammer 8 .Ar cleanup -utility either manually or with a -.Xr cron 8 -job. -For example, to clean-up all -.Nm -file systems in use, including PFSs, every night at 2:15: -.Bd -literal -offset indent -15 2 * * * hammer cleanup >>/var/log/hammer.log 2>&1 -.Ed +metacommand. +By default, +.Dx +is set up to run +.Nm hammer Ar cleanup +nightly via +.Xr periodic 8 . .Pp It is also possible to make these operations individually. For example, to reblock the @@ -324,19 +322,6 @@ pointed to by any snapshot link and is not from after the latest snapshot. rm /snaps/snap1 hammer prune /snaps .Ed -.Pp -Unless the file system is mounted with the -.Ar nohistory -option, it might be advisable to also set up -.Xr cron 8 -jobs for pruning no longer used historical data regularly. -For example, to prune the -.Pa /snaps -directory every night at 3:15 for up to 5 minutes: -.Bd -literal -offset indent -15 3 * * * hammer -c /var/run/snaps.prune -t 300 prune /snaps \e - >/dev/null 2>&1 -.Ed .Ss Mirroring Mirroring can be set up using .Nm Ap s diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5 index 76d549512f..dfca17a643 100644 --- a/share/man/man5/periodic.conf.5 +++ b/share/man/man5/periodic.conf.5 @@ -24,9 +24,9 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/share/man/man5/periodic.conf.5,v 1.8.2.22 2003/02/08 21:42:01 gshapiro Exp $ -.\" $DragonFly: src/share/man/man5/periodic.conf.5,v 1.8 2007/12/29 21:57:58 matthias Exp $ +.\" $DragonFly: src/share/man/man5/periodic.conf.5,v 1.9 2008/10/22 20:15:55 swildner Exp $ .\" -.Dd December 29, 2007 +.Dd October 22, 2008 .Dt PERIODIC.CONF 5 .Os .Sh NAME @@ -247,6 +247,18 @@ Files will be deleted using the same criteria as would normally use when determining whether to believe the cached information, as configured in .Pa /etc/mail/sendmail.cf . +.It Va daily_clean_hammer_enable +.Pq Vt bool +Set to +.Dq YES +if you want +.Xr HAMMER 5 +file systems to be snapshot, pruned and reblocked. +.It Va daily_clean_hammer_verbose +.Pq Vt bool +Set to +.Dq YES +if you wish more verbose output. .It Va daily_backup_passwd_enable .Pq Vt bool Set to -- 2.41.0