The rsnapshot module installs, configures and manages rsnapshot on a dedicated backup server. It allows to set up a centralized Backup Server for all your nodes.
For the cron setup, the module will pick random time entries for the crons from an Array or a Range of time. For how to configure this, [please see below](#more-options)
The defaults are pretty reasonable, I hope. However, you may override pretty much anything. Available parameters are discussed below.
#### Specials
As mentioned, this module will generate random time entries for your hosts. The random number generator is hashed with hostname and backup_level, so the randomness will be repeatable per host.level. This is important so puppet won't override the crons with each run.
You may specify time ranges as follows:
* default cron syntax (1-10, '*/5', 5)
* an array with allowed values, for example, if you want the backup for a host to run between 1am and 5am, you would override the hours setting for the host in question.
in hiera this would look like: (Explanation see below)
```yaml
rsnapshot::hosts:
example.com:
cron:
'daily':
'minute': '1'
'hour': '1..5'
```
This will create the rsnapshot config using defaults from params.pp, but set the minute of the daily backup to '1' and the hour to something random between 1 and 5.
So it would look something like:
```
1 4 * * * foo daily
```
or maybe
```
1 2 * * * foo daily
```
## Reference
### Classes
#### Public Classes
* rsnapshot: Main class, includes all other classes.
####Private Classes
* rsnapshot::install: Handles the packages.
* rsnapshot::config: Handles configuration and cron files.
* rsnapshot::params: default values.
### Functions
####`assert_empty_hash`
Sets an empty value to a hash (we need this so a loop doesn't break if just a hostname is given to pick up all defaults.
####`pick_undef`
Like pick but returns undef values.
####`rand_from_array`
Takes an Integer, a String or an Array as input, and returns a random entry from the array (or just the String/Integer)
### Parameters
The following parameters are available in the `::rsnapshot` class:
####`$hosts`
Hash containing the hosts to be backed up and optional overrides per host
(Default: root, also the user used for ssh connections, if you change this make sure you have proper key deployed and the user exists in the nodes to be backed up.)
Array containing the backup levels (hourly, daily, weekly, monthly)
Configure the backup_levels (valid per host and global, so you may either set: rsnapshot::backup_levels for all hosts or override default backup_levels for specific hosts)
Hash. Set time ranges for different backup levels. Each item (minute, hour...) allows for cron notation, an array to pick a random time from and a range to pick a random time from.
The range notation is '$start..$end', so to pick a random hour from 8 pm to 2 am, you could set the hour of your desired backup level to
`[ '20..23','0..2' ]`
Example:
```puppet
$cron = {
hourly => {
minute => '0..59',
hour => [ '20..23','0..2' ],
}
}
```
Or in hiera:
- global override
```yaml
rsnapshot::cron:
daily:
minute: '20'
weekly:
minute: '20'
```
- per host override
```yaml
rsnapshot::hosts:
webserver:
daily:
hour: [ '20..23','0..2' ]
weekly:
hour: [ '20..23','0..2' ]
```
Hash is of the form:
```puppet
$cron =>{
daily => {
minute => param,
hour => param,
}
weekly => {
minute => param,
hour => param,
}
{...}
}
```
Default is:
```puppet
$cron = {
hourly => {
minute => '0..59', # random from 0 to 59
hour => '*', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '*',
},
daily => {
minute => '0..10', # random from 0 to 10
hour => '0..23', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '*',
},
weekly => {
minute => '0..59',
hour => '0..23', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '0..6',
},
monthly => {
minute => '0..59',
hour => '0..23', # you could also do: ['21..23','0..4','5'],