Giter Site home page Giter Site logo

puppet-rsnapshot's Introduction

rsnapshot

A Puppet module for managing rsnapshot.

Module usage

First you need to create a public/private SSH keypair for rsnapshot, for example with 'ssh-keygen'. Then add the private and public key to Hiera. Then you can include the rsnapshot class and give it the parameters you want:

classes:
    - rsnapshot

rsnapshot::private_key_content: 'your-private-key'
rsnapshot::snapshot_root: '/backup/rsnapshot'
rsnapshot::backups:
    - '/etc/': 'backup.domain.com/'
    - '/var/backups/local/': 'backup.domain.com/'
    - '[email protected]:/etc/': 'server.domain.com/'
rsnapshot::retains:
    - daily: 7
    - weekly: 4
    - monthly: 6
rsnapshot::crons:
    daily:
        minute: 0
        hour: 10
    weekly:
        minute: 0
        hour: 12
        weekday: 3
    monthly:
        minute: 0
        hour: 14
        monthday: 1

Another example from a Puppet profile:

$private_key_content = lookup('profile::rsnapshot::private_key_content', String)
$backups = lookup('profile::rsnapshot::backups')    

class { '::rsnapshot':
    private_key_content => $private_key_content,
    snapshot_root       => '/var/backups/rsnapshot',
    retains             => [  { 'daily'   => 7 }, { 'weekly'  => 4 }, { 'monthly' => 7 }, ],
    crons               => {  'daily'   => { 'minute' => 30, 'hour' => 6, },
                              'weekly'  => { 'minute' => 30, 'hour' => 5, 'weekday'  => 6 },
                              'monthly' => { 'minute' => 30, 'hour' => 4, 'monthday' => 1 }, },
    backups             => $backups, 
}

The "backups" variable in Hiera would be in the same format as above, for example

rsnapshot::backups:
    - '/etc/': 'backup.domain.com/'
    - '/var/backups/local/': 'backup.domain.com/'
    - '[email protected]:/etc/': 'server.domain.com/'

Note that the titles of the rsnapshot::cron resources need to match those given for retains in the main class - here "daily", "weekly" and "monthly". Also note that the "retain" parameters need to be determined in the correct order, or rsnapshot will start "eating" its own backups; the more frequent backups (e.g. "daily") should be defined earlier than and also run before the less frequent ones (e.g. "monthly). Aping the above configuration is probably the safest bet.

Use the rsnapshot::allow class to allow connections to hosts to be backed up:

classes:
    - rsnapshot::allow

rsnapshot::allow::host: '10.122.49.4'
rsnapshot::allow::key: '<rsnapshot's public key as a string>'

The value of host string is added to SSH authorized_keys from option, so that the given key is only valid if the connection matches the host pattern. For example to allow access from multiple IPv4 addresses:

rsnapshot::allow::host: '10.201.5.8,10.122.49.4'

Finally run "rsnapshot daily" or such manually, and accept the SSH keys as needed. Later this manual procedure should be replaced with exported SSH host keys (sshkey type) that are collected on the rsnapshot host.

Monitoring backups

rsnapshot::marker

This module contains a class rsnapshot::marker that can be used to add "backup marker files". The idea is that cron updates the timestamp of the marker file, by default on a daily basis, and that marker file gets backed up.

Example usage:

include rsnapshot::marker

To customize settings:

class { 'rsnapshot::marker':
  path    => '/etc/.my-marker',
  hour    => 5,
  minute  => 0,
  weekday => '1,3,5',
}

rsnapshot::prometheus_metrics

On the rsnapshot server side the timestamps of the marker files allow gathering metrics about backup age, e.g. with Prometheus Node Exporter's Textfile Collector. If marker files are too old, the most likely cause is that backups are failing and an alert should be sent.

The rsnapshot::prometheus_metrics class provides an easy way to generate Prometheus metrics from rsnapshot backups that have marker files. The class builds on top of the prometheus-rsnapshot-metrics script.

Example usage:

include rsnapshot::prometheus_metrics

To customize settings:

class { 'rsnapshot::prometheus_metrics':
  metrics_file            => '/var/lib/node_exporter/textfile_collector/rsnapshot.prom',
  latest_backup_directory => '/backup/daily.0',
  marker_name             => '.my-marker',
  max_backup_age_days     => 4,
  max_depth               => 3,
  hour                    => 6,
  minute                  => 0,
  weekday                 => '1,3,5',
}

Reference

For more details on module usage refer to these source files:

puppet-rsnapshot's People

Contributors

mattock avatar

Watchers

James Cloos avatar Mikko Vilpponen avatar  avatar  avatar

puppet-rsnapshot's Issues

Warnings: The parameter '$hour' must be a literal type, not a Puppet::Pops::Model::AccessExpression

The parameter '$hour' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: .modules/rsnapshot/manifests/marker.pp, line: 18, column: 71)
The parameter '$minute' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: .modules/rsnapshot/manifests/marker.pp, line: 19, column: 71)
The parameter '$weekday' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: .modules/rsnapshot/manifests/marker.pp, line: 20, column: 71)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.