Skip to content

Commit

Permalink
Add a tar handler modeled after the rdiff handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Saford91 committed Oct 19, 2016
1 parent 996f262 commit cc6bfd1
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
13 changes: 13 additions & 0 deletions manifests/client/tar.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# == Class: backupninja::client::tar
#
# Manage tar installation
class backupninja::client::tar inherits backupninja::client::defaults {
if !defined(Package['tar']) {
if $tar_ensure_version == '' {
$tar_ensure_version = 'installed'
}
package { 'tar':
ensure => $tar_ensure_version,
}
}
}
61 changes: 61 additions & 0 deletions manifests/tar.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Run tar as part of a backupninja run.
#
# Valid attributes for this type are:
#
# order: The prefix to give to the handler config filename, to set
# order in which the actions are executed during the backup run.
#
# ensure: Allows you to delete an entry if you don't want it any more
# (but be sure to keep the configdir, name, and order the same, so
# that we can find the correct file to remove).
#
# include, exclude, compress, dateformat: As
# defined in the backupninja documentation. The options will be placed
# in the correct sections automatically. The include and exclude
# options should be given as arrays if you want to specify multiple
# directories.
#
define backupninja::tar (
$order = 90,
$ensure = present,
$when = "everyday at 01:00",
$backupname = "${fqdn}",
$backupdir = '/var/backups',
$compress = "bzip",
$dateformat = "%Y.%m.%d-%H%M",
$exclude = [
$directory,
'/home/*/.gnupg',
'/home/*/.local/share/Trash',
'/home/*/.Trash',
'/home/*/.thumbnails',
'/home/*/.beagle',
'/home/*/.aMule',
'/home/*/gtk-gnutella-downloads',
'/tmp',
'/proc',
'/dev',
'/sys',
'/net',
'/misc',
'/media',
'/srv',
'/selinux',
],
$include = [
'/etc',
'/home',
'/usr/local',
],

) {
include ::backupninja::client::tar
file { "${backupninja::client::defaults::configdir}/${order}_${name}.tar":
ensure => $ensure,
content => template('backupninja/tar.conf.erb'),
owner => root,
group => root,
mode => '0600',
require => File[$backupninja::client::defaults::configdir],
}
}
22 changes: 22 additions & 0 deletions templates/tar.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This configuration file was auto-generated by the Puppet configuration
# management system. Any changes you make to this file will be overwritten
# the next time Puppet runs. Please make configuration changes to this
# service in Puppet.

<%= 'when = ' + @when if @when %>
<%= 'backupdir = ' + @backupdir if @backupdir %>
<%= 'backupname = ' + @backupname if @backupname %>
<%= 'compress = ' + @compress if @compress %>
<% if @include.is_a? String -%>
<%= 'includes = ' + @include %>
<% elsif @include.is_a? Array -%>
<%= 'includes = ' + @include.map { |i| "#{i}" }.join(" ") %>
<% end -%>

<% if @exclude.is_a? String -%>
<%= 'excludes = ' + @exclude %>
<% elsif @exclude.is_a? Array -%>
<%= 'excludes = ' + @exclude.map { |i| "#{i}" }.join(" ") %>
<% end -%>

<%= 'DATEFORMAT = ' + @dateformat if $dateformat %>

0 comments on commit cc6bfd1

Please sign in to comment.