212 lines
6.8 KiB
Bash
Executable File
212 lines
6.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
apt install -y libconfig-inifiles-perl git
|
|
|
|
cd /opt
|
|
git clone http://github.com/jimsalterjrs/sanoid
|
|
|
|
ln -s /opt/sanoid/sanoid /usr/sbin/
|
|
|
|
mkdir -p /etc/sanoid
|
|
cp /opt/sanoid/sanoid.conf /etc/sanoid/sanoid.conf
|
|
cp /opt/sanoid/sanoid.defaults.conf /etc/sanoid/sanoid.defaults.conf
|
|
|
|
# ###################################################################################
|
|
# # default template - DO NOT EDIT THIS FILE DIRECTLY. #
|
|
# # If you wish to override default values, you can create your #
|
|
# # own [template_default] in /etc/sanoid/sanoid.conf. #
|
|
# # #
|
|
# # you have been warned. #
|
|
# ###################################################################################
|
|
#
|
|
# [template_default]
|
|
#
|
|
# # these settings don't make sense in a template, but we use the defaults file
|
|
# # as our list of allowable settings also, so they need to be present here even if
|
|
# # unset.
|
|
# path =
|
|
# recursive =
|
|
# use_template =
|
|
# process_children_only =
|
|
#
|
|
# # If any snapshot type is set to 0, we will not take snapshots for it - and will immediately
|
|
# # prune any of those type snapshots already present.
|
|
# #
|
|
# # Otherwise, if autoprune is set, we will prune any snapshots of that type which are older
|
|
# # than (setting * periodicity) - so if daily = 90, we'll prune any dailies older than 90 days.
|
|
# autoprune = yes
|
|
# hourly = 48
|
|
# daily = 90
|
|
# monthly = 6
|
|
# yearly = 0
|
|
# min_percent_free = 10
|
|
#
|
|
# # We will automatically take snapshots if autosnap is on, at the desired times configured
|
|
# # below (or immediately, if we don't have one since the last preferred time for that type).
|
|
# #
|
|
# # Note that we will not take snapshots for a given type if that type is set to 0 above,
|
|
# # regardless of the autosnap setting - for example, if yearly=0 we will not take yearlies
|
|
# # even if we've defined a preferred time for yearlies and autosnap is on.
|
|
# autosnap = 1;
|
|
# # hourly - top of the hour
|
|
# hourly_min = 0;
|
|
# # daily - at 23:59 (most people expect a daily to contain everything done DURING that day)
|
|
# daily_hour = 23;
|
|
# daily_min = 59;
|
|
# # monthly - immediately at the beginning of the month (ie 00:00 of day 1)
|
|
# monthly_mday = 1;
|
|
# monthly_hour = 0;
|
|
# monthly_min = 0;
|
|
# # yearly - immediately at the beginning of the year (ie 00:00 on Jan 1)
|
|
# yearly_mon = 1;
|
|
# yearly_mday = 1;
|
|
# yearly_hour = 0;
|
|
# yearly_min = 0;
|
|
#
|
|
# # monitoring plugin - define warn / crit levels for each snapshot type by age, in units of one period down
|
|
# # example hourly_warn = 90 means issue WARNING if most recent hourly snapshot is not less than 90 minutes old,
|
|
# # daily_crit = 36 means issue CRITICAL if most recent daily snapshot is not less than 36 hours old,
|
|
# # monthly_warn = 36 means issue WARNING if most recent monthly snapshot is not less than 36 days old... etc.
|
|
# #
|
|
# # monitor_dont_warn = yes will cause the monitoring service to report warnings as text, but with status OK.
|
|
# # monitor_dont_crit = yes will cause the monitoring service to report criticals as text, but with status OK.
|
|
# #
|
|
# # setting any value to 0 will keep the monitoring service from monitoring that snapshot type on that section at all.
|
|
# monitor = yes
|
|
# monitor_dont_warn = no
|
|
# monitor_dont_crit = no
|
|
# hourly_warn = 90
|
|
# hourly_crit = 360
|
|
# daily_warn = 28
|
|
# daily_crit = 32
|
|
# monthly_warn = 32
|
|
# monthly_crit = 35
|
|
# yearly_warn = 0
|
|
# yearly_crit = 0
|
|
|
|
## Examples
|
|
#
|
|
# * * * * * /usr/local/bin/sanoid --cron
|
|
#
|
|
# Only crontab entry you'll ever need. (You're of course perfectly welcome to do something like
|
|
#
|
|
# 0 * * * * /usr/local/bin/sanoid --cron
|
|
#
|
|
# instead if you want to limit number of executions possible.) different number of snapshots per volume
|
|
#
|
|
# Super easy. You can use templates, write your own templates, or override individual settings within a
|
|
# template.
|
|
#
|
|
# Some example usage, including recursive application (will apply to datasets that are children of the
|
|
# dataset being configured) and non-recursive, a custom template, and overriding individual settings in
|
|
# a template:
|
|
|
|
#/etc/sanoid/sanoid.conf:
|
|
#
|
|
#[pool/dataset1]
|
|
# use_template=production
|
|
# daily=60
|
|
# recursive=yes
|
|
#
|
|
#[pool/dataset2]
|
|
# use_template=production
|
|
# daily=15
|
|
# hourly=24
|
|
# recursive=yes
|
|
#
|
|
#[pool/dataset3]
|
|
# use_template=mytemplate
|
|
#
|
|
#[pool/dataset3/dataset4]
|
|
# use_template=production
|
|
#
|
|
##########################
|
|
#
|
|
#[template_production]
|
|
# hourly = 36
|
|
# daily = 30
|
|
# monthly = 3
|
|
# yearly = 0
|
|
# autosnap = yes
|
|
# autoprune = yes
|
|
#
|
|
#[template_mytemplate]
|
|
# hourly = 5
|
|
# daily = 10
|
|
# monthly = 0
|
|
# yearly = 0
|
|
# autosnap = yes
|
|
# autoprune = yes
|
|
|
|
cat > /etc/sanoid/sanoid.conf << 'EOF'
|
|
######################################
|
|
# This is a sample sanoid.conf file. #
|
|
# It should go in /etc/sanoid. #
|
|
######################################
|
|
|
|
# name your backup modules with the path to their ZFS dataset - no leading slash.
|
|
[zpoolname/datasetname]
|
|
# pick one or more templates - they're defined (and editable) below. Comma separated, processed in order.
|
|
# in this example, template_demo's daily value overrides template_production's daily value.
|
|
use_template = production,demo
|
|
|
|
# if you want to, you can override settings in the template directly inside module definitions like this.
|
|
# in this example, we override the template to only keep 12 hourly and 1 monthly snapshot for this dataset.
|
|
hourly = 12
|
|
monthly = 1
|
|
|
|
# you can also handle datasets recursively.
|
|
[zpoolname/parent]
|
|
use_template = production
|
|
recursive = yes
|
|
# if you want sanoid to manage the child datasets but leave this one alone, set process_children_only.
|
|
process_children_only = yes
|
|
|
|
# you can selectively override settings for child datasets which already fall under a recursive definition.
|
|
[zpoolname/parent/child]
|
|
# child datasets already initialized won't be wiped out, so if you use a new template, it will
|
|
# only override the values already set by the parent template, not replace it completely.
|
|
use_template = demo
|
|
|
|
|
|
|
|
|
|
#############################
|
|
# templates below this line #
|
|
#############################
|
|
|
|
# name your templates template_templatename. you can create your own, and use them in your module definitions above.
|
|
|
|
[template_demo]
|
|
daily = 60
|
|
|
|
[template_production]
|
|
hourly = 36
|
|
daily = 30
|
|
monthly = 3
|
|
yearly = 0
|
|
autosnap = yes
|
|
autoprune = yes
|
|
|
|
[template_backup]
|
|
autoprune = yes
|
|
hourly = 30
|
|
daily = 90
|
|
monthly = 12
|
|
yearly = 0
|
|
|
|
### don't take new snapshots - snapshots on backup
|
|
### datasets are replicated in from source, not
|
|
### generated locally
|
|
autosnap = no
|
|
|
|
### monitor hourlies and dailies, but don't warn or
|
|
### crit until they're over 48h old, since replication
|
|
### is typically daily only
|
|
hourly_warn = 2880
|
|
hourly_crit = 3600
|
|
daily_warn = 48
|
|
daily_crit = 60
|
|
EOF
|
|
|
|
|