Initial working draft of the new replicate algorithm using
[zfs-nexenta/.git] / zfs-autosnap-wrapper
1 #!/bin/bash
2
3 # Author: Alan J. Pippin
4 # Description: This script is a wrapper script that calls zfs-autosnap
5 #              for each filesystem provided below.
6
7 # Setup some default values
8 autosnap="/usr/local/etc/bin/zfs-autosnap"
9 logfile="/var/log/zfs/zfs-autosnap.log"
10 lockdir="/tmp/zfs-autosnap-all"
11 numsnapshots=20
12 maxagedays=365
13 date=`date`
14
15 # Make sure we aren't already running
16 if ! mkdir "$lockdir" >/dev/null 2>&1; then
17   echo "$date Another $0 process is already running" >> $logfile
18   exit 1
19 fi
20
21 # Auto snapshot every zfs filesystem on the system specified below
22 date >> $logfile
23
24 # Special filesystems
25 $autosnap storage /storage $numsnapshots 15
26 $autosnap tank/usr/videos /usr/videos $numsnapshots 15
27
28 # Normal filesystems
29 $autosnap tank / $numsnapshots $maxagedays 
30 $autosnap tank/backup /backup $numsnapshots $maxagedays
31 $autosnap tank/usr /usr $numsnapshots $maxagedays
32 $autosnap tank/usr/home /usr/home $numsnapshots $maxagedays
33 $autosnap tank/usr/local /usr/local $numsnapshots $maxagedays
34 $autosnap tank/usr/local/etc /usr/local/etc $numsnapshots $maxagedays
35
36 # Daily filesystems (only perform these at midnight)
37 if [ `date +"%H:%M"` == "00:00" ]; then 
38    echo "Performing Daily snapshots" >> $logfile
39 fi
40
41 # Weekly filesystems (only perform these on Sunday at midnight)
42 if [ `date +"%H:%M:%u"` == "00:00:7" ]; then
43   echo "Performing Weekly snapshots" >> $logfile
44   $autosnap tank/var /var $numsnapshots 60
45   $autosnap tank/usr/local/var /usr/local/var $numsnapshots 60
46 fi
47
48 rm -rf "$lockdir"