Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tar handler modeled after the rdiff handler #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
}
}
50 changes: 27 additions & 23 deletions manifests/duplicity.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
],
$vsinclude = false,
# [dest]
$local = false,
$incremental = 'yes',
$increments = 30,
$keep = false,
$bandwidthlimit = false,
$sshoptions = false,
Expand All @@ -98,31 +100,33 @@
# the client with configs for this machine
include backupninja::client::defaults

validate_string($desthost)
validate_string($destdir)
validate_string($password)
if !$local {
validate_string($desthost)
validate_string($destdir)
validate_string($password)

# guarantees there's a configured backup space for this backup
backupninja::server::sandbox { "${user}-${name}":
user => $destuser,
host => $desthost,
dir => $destdir,
manage_ssh_dir => $ssh_dir_manage,
ssh_dir => $ssh_dir,
authorized_keys_file => $authorized_keys_file,
installuser => $installuser,
backuptag => $backuptag,
backupkeys => $backupkeystore,
keytype => $backupkeytype,
}
# guarantees there's a configured backup space for this backup
backupninja::server::sandbox { "${user}-${name}":
user => $destuser,
host => $desthost,
dir => $destdir,
manage_ssh_dir => $ssh_dir_manage,
ssh_dir => $ssh_dir,
authorized_keys_file => $authorized_keys_file,
installuser => $installuser,
backuptag => $backuptag,
backupkeys => $backupkeystore,
keytype => $backupkeytype,
}

# the client's ssh key
backupninja::client::key { "${destuser}-${name}":
user => $destuser,
host => $desthost,
installkey => $installkey,
keytype => $backupkeytype,
keystore => $backupkeystore,
# the client's ssh key
backupninja::client::key { "${destuser}-${name}":
user => $destuser,
host => $desthost,
installkey => $installkey,
keytype => $backupkeytype,
keystore => $backupkeystore,
}
}

# the backupninja rule for this duplicity backup
Expand Down
3 changes: 2 additions & 1 deletion manifests/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# that we can find the correct file to remove).
#
# user, dbusername, dbpassword, dbhost, databases, backupdir,
# hotcopy, sqldump, compress, configfile: As defined in the
# hotcopy, sqldump, sqldumpoptions, compress, configfile: As defined in the
# backupninja documentation, with the caveat that hotcopy, sqldump,
# and compress take true/false rather than yes/no.
#
Expand All @@ -25,6 +25,7 @@
$backupdir = false,
$hotcopy = false,
$sqldump = false,
$sqldumpoptions = '',
$compress = false,
$configfile = true,
$vsname = false,
Expand Down
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 = [
$backupdir,
'/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],
}
}
5 changes: 5 additions & 0 deletions templates/dup.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@

[dest]
<%= 'incremental = ' + @incremental if @incremental %>
<%= 'increments = ' + @increments if @increments %>
<%= 'keep = ' + @keep if @keep %>
<%= 'bandwidthlimit = ' + @bandwidthlimit if @bandwidthlimit %>
<%= 'sshoptions = ' + @sshoptions if @sshoptions %>
<% if @local -%>
<%= 'desturl = file://' + @destdir if @destdir %>
<% else -%>
<%= 'destdir = ' + @destdir if @destdir %>
<%= 'desthost = ' + @desthost if @desthost %>
<%= 'destuser = ' + @destuser if @destuser %>
<% end -%>
13 changes: 12 additions & 1 deletion templates/mysql.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,16 @@ configfile = <%= @real_configfile %>
<% end -%>

hotcopy = <%= @hotcopy ? 'yes' : 'no' %>
sqldump = <%= @sqldump ? 'yes' : 'no' %>

<% if @sqldump -%>
sqldump = yes
<% if @sqldumpoptions.is_a? String -%>
<%= 'sqldumpoptions = ' + @sqldumpoptions %>
<% elsif @sqldumpoptions.is_a? Array -%>
<%= 'sqldumpoptions = ' + @sqldumpoptions.map { |i| "#{i}" }.join(" ") %>
<% end -%>
<% else -%>
sqldump = no
<% end -%>

compress = <%= @compress ? 'yes' : 'no' %>
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 %>