README 5.09 KB
Newer Older
Micah Anderson's avatar
Micah Anderson committed
1 2 3
Backupninja Module
-------------------

4
This module helps you configure all of your backups with puppet, using
5
backupninja!
Micah Anderson's avatar
Micah Anderson committed
6

7
!! UPGRADE NOTICE !!
Micah Anderson's avatar
Micah Anderson committed
8

9 10
If you were previously using this module, some pieces have changed,
and you need to carefully change your use of them, or you will find
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
your backups could stop working.

The backupninja::client class has been renamed to backupninja, and is
now *required* in all node manifests. Make sure the backupninja class
is now declared in all your node manifests! This new class now defines
defaults which were previously provided by backupninja::client::defaults,
and can now be overridden thanks to the brand new technology of class
parameters. This class also manages the backupninja configuration file,
replacing the backupninja::config ressource.

The backupninja::server class has some minor changes, including some
changes related to the nagios passive checks. See the code for details.

Handlers are *mostly* unchanged.

See below for dependencies which have been introduced in this version.

Dependencies
29 30
---------------

31
This module requires Puppet versions 2.7 and up.
32

33
An up-to-date version of the puppet-stdlib module is also required.
34 35 36 37 38 39

Configure your backup server
----------------------------

Now you will need to configure a backup server by adding the following
to your node definition for that server:
40

41 42
  include backupninja::server

43 44 45 46 47 48 49 50
The default configuration will store backup data in the "/backup"
directory. To change this you may declare the class with a "backupdir"
parameter:

  class { 'backupninja::server':
    backupdir => '/mnt/backupdata'
  }

51 52
By configuring a backupninja::server, this module will automatically
create sandboxed users on the server for each client for their
53
backups.
Micah Anderson's avatar
Micah Anderson committed
54

55 56 57
Configure your backup clients
-----------------------------

58 59
First, you need to include the backupninja class or declare it with
custom parameters:
60

61 62 63 64 65 66 67 68
  class { 'backupninja':
	loglvl => 3,
	usecolors => false,
	reportsuccess => false,
	reportwarning => true,
    ensure_backupninja_version => '1.0.1-1',
    ensure_rdiffbackup_version => '1.2.8-7'
  }
69 70

In this case, the module will make sure that the backupninja package
71 72 73 74 75 76 77
is installed (using puppet's ensure parameter language) and create the
/etc/backupninja.conf configuration file.

If you need to specify a specific version of either backupninja itself,
or the specific programs that the handler class installs, you can
specify the version you need installed by providing a class parameter,
as shown in the example.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

Configuring handlers
--------------------

Depending on which backup method you want to use on your client, you
can simply specify some configuration options for that handler that are
necessary for your client.

Each handler has its own configuration options necessary to make it
work, each of those are available as puppet parameters. You can see
the handler documentation, or look at the handler puppet files
included in this module to see your different options.

Included below are some configuration examples for different handlers.

* An example mysql handler configuration:
Micah Anderson's avatar
Micah Anderson committed
94

95
backupninja::mysql { 'all_databases':
Micah Anderson's avatar
Micah Anderson committed
96 97 98 99 100 101
	user => root,
	backupdir => '/var/backups',
	compress => true,
	sqldump => true
}

102 103
* An example rdiff-backup handler configuration:

104
backupninja::rdiff { 'backup_all':
Micah Anderson's avatar
Micah Anderson committed
105 106 107 108 109
	directory => '/media/backupdisk',
	include => ['/var/backups', '/home', '/var/lib/dpkg/status'],
	exclude => '/home/*/.gnupg'
}

110
* A remote rdiff-backup handler:
111

112 113 114 115 116
backupninja::rdiff { 'main':
    host => 'backup.example.com',
    type => 'remote',
    directory => "/backup/${::fqdn}",
    user => "backup-${::hostname}",
117
}
118

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
Automatic creation of ssh-keys for duplicity
--------------------------------------------

backupninja::duplicity can be used to

- create an ssh keypair for a client
- place the keypair on the puppetmaster in a given location
- place the keypair in /root/.ssh on the client

i.e.:

  backupninja::duplicity { "duplicity_${::fqdn}":
    sshoptions        => "-oIdentityFile=/root/.ssh/backupninja_${::hostname}_id_rsa",
    desthost          => 'HOST',
    destdir           => "/var/backup/backupninja/${::fqdn}",
    destuser          => "backupninja_${::hostname}",
    encryptkey        => 'KEYID',
    password          => 'PW',
    backupkeystore    => 'puppet:///keys',
    backupkeystorefspath => '/etc/puppet/modules/keys/files',
    backupkeydestname => "backupninja_${::hostname}_id_rsa",
    createkey         => true,
    installkey        => true,
    ...
  }


146 147 148
Nagios alerts about backup freshness
------------------------------------

149 150 151
If you set the $backupninja::server::nagios_server variable to be the
name of your nagios server, then a passive nagios service gets setup so
that the backup server pushes checks, via a cronjob that calls
152 153
/usr/local/bin/checkbackups.pl, to the nagios server to alert about
relative backup freshness.
154

155 156 157 158 159
To use this feature a few pre-requisites are necessary:

 . configure nsca on your backup server (not done via puppet yet)
 . configure nsca on your nagios server (not done via puppet yet)
 . server backup directories are named after their $fqdn
160
 . backups must be under $home/dup, $home/rdiff-backup depending on method