rdiff.pp 2.55 KB
Newer Older
Micah Anderson's avatar
Micah Anderson committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Run rdiff-backup 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).
#
#   keep, include, exclude, type, host, directory, user, sshoptions: 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.
# 
18 19 20 21 22 23 24 25
define backupninja::rdiff(
  $order = 90, $ensure = present, $user = false, $directory = false, $host = false,
  $type = 'local',
  $exclude = [ "/home/*/.gnupg", "/home/*/.local/share/Trash", "/home/*/.Trash",
               "/home/*/.thumbnails", "/home/*/.beagle", "/home/*/.aMule",
               "/home/*/gtk-gnutella-downloads" ],
  $include = [ "/var/spool/cron/crontabs", "/var/backups", "/etc", "/root",
               "/home", "/usr/local/*bin", "/var/lib/dpkg/status*" ],
26
  $vsinclude = false, $keep = 30, $sshoptions = false, $options = false, $ssh_dir_manage = true,
27
  $ssh_dir = false, $authorized_keys_file = false, $installuser = true, $installkey = true,
28
  $backuptag = false, $home = false, $backupkeytype = "rsa")
29
{
30
  include backupninja::client::defaults
31 32 33

  case $directory { false: { err("need to define a directory for where the backups should go!") } }
  
34 35 36 37
  case $type {
    'remote': {
      case $host { false: { err("need to define a host for remote backups!") } }
      
Silvio Rhatto's avatar
Silvio Rhatto committed
38 39 40 41 42
      $real_home = $home ? {
        false => $directory,
        default => $home,
      }

43 44
      backupninja::server::sandbox
      {
45
        "${user}-${name}": user => $user, host => $host, dir => $real_home,
46
        manage_ssh_dir => $ssh_dir_manage, ssh_dir => $ssh_dir,
47
        authorized_keys_file => $authorized_keys_file, installuser => $installuser,
48
        backuptag => $backuptag, keytype => $backupkeytype,
49
      }
50
     
51 52 53 54
      backupninja::client::key
      {
        "${user}-${name}": user => $user, host => $host,
        installkey => $installkey
55 56 57
      }
    }
  }
58
  file { "${backupninja::client::defaults::configdir}/${order}_${name}.rdiff":
59 60 61 62 63
    ensure => $ensure,
    content => template('backupninja/rdiff.conf.erb'),
    owner => root,
    group => root,
    mode => 0600,
64
    require => File["${backupninja::client::defaults::configdir}"]
65
  }
Micah Anderson's avatar
Micah Anderson committed
66
}
67