Forge Home

pe_backup

Module to manage minimalistic Puppet Enterprise backups

7,248 downloads

6,932 latest version

4.3 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.2 (latest)
  • 1.0.1
  • 1.0.0
released Apr 18th 2017
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.4.0 < 5.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'fvoges-pe_backup', '1.0.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add fvoges-pe_backup
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install fvoges-pe_backup --version 1.0.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

fvoges/pe_backup — version 1.0.2 Apr 18th 2017

Puppet pe_backup Module

Build Status

Table of Contents

  1. Overview
  2. Module Description
  3. Setup
  4. Usage
  5. Reference
  6. Limitations
  7. Development

Overview

pe_backup is a minimal implementation of a Puppet Enterprise backup. It only takes a backup of the directories recommended by the documentation.

This module doesn't backup the databases, you might want to check npwalker/pe_databases for that.

Module Description

The module manages two resources, a backup script and a cron job to run the script.

This release doesn't include a restore script. To do a restore, just follow the instructions from the documentation.

Setup

What pe_backup affects

Using the default settings, pe_backup will install a backup script /usr/local/bin/pe_backup.sh and add a cron job to run that script every day at 3:33am.

Beginning with pe_backup

The module should work without changing any of the default parameters and only requires specifying the destination for the backup using the destinationparameter.

NOTE: the module expects the destination directory to exist. It will not try to create it. It's better to manage that from a profile instead of trying to work out all the possible cases inside this module.

Usage

Getting started

The basic use case requires passing the destination directory to the pe_backup class:

class { 'pe_backup':
  destination => '/vol/backups/pe_backups',
}

The first time that that code is applied to a node, it will create the backup script /urs/local/bin/pe_backup.sh and a cron job for the root user to run it every day at 3:33am.

The backups will be stored in the location specified with the destination parameter using the naming pe_backup-YYYYMMDDHHMM.tar.bz2. Where pe_backup is the default prefix and YYYYMMDDHHMM is the current time stamp at the time the script was executed.

Specify a file name prefix for the backup

By default, the backups created will use the default prefix (pe_backup). The prefix can be altered to use something else by specifying the prefix parameter.

The following example uses the trusted fact certname as the file prefix.

class { '::pe_backup':
  destination => $destination,
  prefix      => $::trusted['certname'],
}

Specify extra directory to backup

Example profile working together with npwalker/pe_databases.

This example uses the

# Profile profile::puppet::backup
class profile::puppet::backup {
  $destination = hiera('profile::puppet::backup::destination')

  include ::pe_databases::backup

  file { $destination:
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0750',
  }

  class { '::pe_backup':
    destination => $destination,
    prefix      => $::trusted['certname'],
    # include the database dumps fron pe_databases::backup too
    dirs_extra  => [ $pe_databases::backup::backup_directory, ],
  }
}

Reference

Classes

Public Classes

  • pe_backup: Installs and configures the PE backup script

Private Classes

Parameters

pe_backup

destination (Stdlib::Absolutepath)

Destination directory for the backups.

Valid values are any valid UNIX absolute path.

Mandatory.

user (String)

Backup script owner user.

Defaults to root.

group (String)

Backup script owner group.

Defaults to root.

umask (String)

Sets the umask inside the backup script.

Defaults to 0077.

prefix (String)

Backup file name prefix.

Defaults to pe_backup.

script (Stdlib::Absolutepath)

Backup script name including absolute path.

Valid values are any valid UNIX absolute path including file name.

Defaults to /usr/local/bin/pe_backup.sh.

hour (String)

Crontab hour for the backup.

Valid values are the ones for the cron type.

Defaults to 3.

minute (String)

Crontab minute for the backup.

Valid values are the ones for the cron type.

Defaults to 33.

weekday (String)

Crontab weekday for the backup.

Valid values are the ones for the cron type.

Defaults to * (everyday).

nodetype (Enum)

Puppet node type. Allows to customize the backed up directories based for different types of Puppet servers (Master, PuppetDB, Console, etc.).

Valid values are monolithic, master, db, or console.

Defaults to monolithic.

dirs_common (Array)

List of directories that need to be backed up on all node types. This shouldn't need changing in most cases.

Valid values are any Array containing a list of absolute paths. Use dirs_extra to specify additional directories.

Defaults to '/etc/puppetlabs'.

dirs_master (Array)

List of directories that need to be backed up on a Puppet Master node. This shouldn't need changing in most cases. Use dirs_extra to specify additional directories.

Valid values are any Array containing a list of absolute paths.

Defaults to [] (empty array).

dirs_db (Array)

List of directories that need to be backed up on a PuppetDB node. This shouldn't need changing in most cases. Use dirs_extra to specify additional directories.

Valid values are any Array containing a list of absolute paths.

Defaults to [ '/opt/puppetlabs/server/data/postgresql/9.4/data/certs', ].

dirs_console (Array)

List of directories that need to be backed up on a Puppet Console node. This shouldn't need changing in most cases. Use dirs_extra to specify additional directories.

Valid values are any Array containing a list of absolute paths.

Defaults to [ '/opt/puppetlabs/server/data/console-services/certs', ].

dirs_extra (Array)

List of additional directories that need to be backed up on a node. Most likely to be used to backup the database dumps.

Valid values are any Array containing a list of absolute paths.

Defaults to [] (empty array).

Limitations

  • No restore functionality yet.
  • No ability to set the backup retention policy. yet.
    • Work around: Use a cron job to delete the old backups.
  • The script doesn't check to see if another backup is in progress.

Development

Feel free to send bug reports and pull requests to the project page.