Skip to content

Commit

Permalink
Merge pull request #10 from evilham/quarter-hourly
Browse files Browse the repository at this point in the history
quarter_hourly: add disabled by default support
  • Loading branch information
ross committed Jul 5, 2023
2 parents 1af2ee1 + b371034 commit 9004e37
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/crontab
Expand Up @@ -16,6 +16,7 @@ PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
0 * * * * root newsyslog
#
# Perform daily/weekly/monthly maintenance.
#*/15 * * * * root periodic quarter_hourly
1 * * * * root periodic hourly
1 3 * * * root periodic daily
15 4 * * 6 root periodic weekly
Expand Down
8 changes: 8 additions & 0 deletions etc/periodic.conf
Expand Up @@ -10,6 +10,14 @@ hourly_zfs_snapshot_pools="tank" # space seperated list of pools or datasets
hourly_zfs_snapshot_keep=3
hourly_zfs_snapshot_skip="" # space seperated list of datasets to skip

# Quarter hourly options

# 000.zfs-snapshot
#quarter_hourly_zfs_snapshot_enable="YES"
#quarter_hourly_zfs_snapshot_pools="tank"
#quarter_hourly_zfs_snapshot_keep=8
#quarter_hourly_zfs_snapshot_skip=""

# Daily options

# 000.zfs-snapshot
Expand Down
28 changes: 28 additions & 0 deletions etc/periodic/quarter_hourly/000.zfs-snapshot
@@ -0,0 +1,28 @@
#!/bin/sh

# 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

pools=$quarter_hourly_zfs_snapshot_pools
if [ -z "$pools" ]; then
pools='tank'
fi

keep=$quarter_hourly_zfs_snapshot_keep
if [ -z "$keep" ]; then
keep=8
fi

case "$quarter_hourly_zfs_snapshot_enable" in
[Yy][Ee][Ss])
. /etc/periodic/zfs-snapshot
do_snapshots "$pools" $keep 'quarter_hourly' "$quarter_hourly_zfs_snapshot_skip"
;;
*)
;;
esac
7 changes: 7 additions & 0 deletions etc/periodic/zfs-snapshot
Expand Up @@ -6,6 +6,9 @@ create_snapshot()
pool=$1

case "$type" in
quarter_hourly)
now=`date +"$type-%Y-%m-%d-%H-%M"`
;;
hourly)
now=`date +"$type-%Y-%m-%d-%H"`
;;
Expand Down Expand Up @@ -71,6 +74,10 @@ do_pool()
# create the regex matching the type of snapshots we're currently working
# on
case "$type" in
quarter_hourly)
# quarter_hourly-2009-01-01-00-15
regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$"
;;
hourly)
# hourly-2009-01-01-00
regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$"
Expand Down

0 comments on commit 9004e37

Please sign in to comment.