Forge Home

backup

Backs up files before changing them, even if you don't know how they get changed.

7,314 downloads

6,104 latest version

4.6 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.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.2.4 (latest)
  • 0.2.3
  • 0.2.2
  • 0.2.1
  • 0.2.0
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Jul 6th 2017
This version is compatible with:
  • Debian, RedHat, Ubuntu, Windows, Solaris, AIX

Start using this module

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

Add this module to your Puppetfile:

mod 'dylanratcliffe-backup', '0.2.4'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add dylanratcliffe-backup
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install dylanratcliffe-backup --version 0.2.4

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

dylanratcliffe/backup — version 0.2.4 Jul 6th 2017

Backup module

Backs up files before changing them, even if you don't know how they get changed.

This module allows you to ensure that Puppet backs up critical files before it touches them, even if you are using a forge module to manage those files and you don't know how it actually works under the hood.

Defined Types

backup

This defined type causes puppet to back up a file before it changes it. This functionality is different to that of the Filebucket in that it can back up files regardless of the type of resource that is changing them. Filebucket on the other hand only works with file resources. The functionality that this provides is implemented by the puppetlabs/transition module which allows puppet to modify the state of one resource before it goes to change another.

In this case is creates a backup if a given file, before changing the $watch resource or class.

This defined type also supports restoring files from a backup. Simply set ensure to restored and the file will copied from the backup directory. Please not that this may cause duplicate declaration or loops where Puppet restored the file then changes it again. You will likely need to comment out the class that caused the erroneous change to get this to work properly.

Parameters

watch: The resource or class to watch. If this resource/class is going to change, a backup will be created

backup_dir: Where to put the backups. This defaults to relative, meaning that the backup file will be put in the same location as the original file, but with the version appended.

file: The file to back up

ensure: backed_up or restored

version: This allows you to specify a string to be assigned to the backup version. If this parameter is set, the file will be backed up once per version, the first time it is touched. This allows us to set the version to pre_puppet and maintain a backup of the state of the file before it was managed by Puppet. This state will not be overwritten. When restoring files the version parameter refers to which version to restore. If version is not specified, backup keeps the previous version of the file.

Examples

Backing up ssh config

backup { '/etc/ssh/sshd_config':
  ensure        => 'backed_up',
  backup_before => Class['::ssh'],
}

Backing up ssh config to a specific location

backup { '/etc/ssh/sshd_config':
  ensure        => 'backed_up',
  backup_before => Class['::ssh'],
  backup_dir    => '/var/backups',
}