rsync.pp 3.2 KB
Newer Older
Silvio Rhatto's avatar
Silvio Rhatto committed
1 2
# Run rsync as part of a backupninja run.
# Based on backupninja::rdiff
3
# Right now just local origin and remote destination is supported.
Silvio Rhatto's avatar
Silvio Rhatto committed
4 5 6

define backupninja::rsync(
  $order = 90, $ensure = present, $user = false, $home = false, $host = false,
Silvio Rhatto's avatar
Silvio Rhatto committed
7 8
  $ssh_dir_manage = true, $ssh_dir = false, $authorized_keys_file = false,
  $installuser = true, $installkey = true, $key = false, $backuptag = false,
Silvio Rhatto's avatar
Silvio Rhatto committed
9 10 11
  $home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false,
  $nagios2_description = 'backups', $subfolder = 'rsync',

12
  # general
Silvio Rhatto's avatar
Silvio Rhatto committed
13 14 15 16 17
  $log = false, $partition = false, $fscheck = false, $read_only = false,
  $mountpoint = false, $backupdir = false, $format = false, $days = '5',
  $keepdaily = false, $keepweekly = false, $keepmonthly = false, $lockfile = false,
  $nicelevel = 0, $enable_mv_timestamp_bug = false, $tmp = false, $multiconnection = false,

18 19
  # source
  $from = 'local', $exclude_vserver = false,
Silvio Rhatto's avatar
Silvio Rhatto committed
20 21 22 23 24 25
  $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 27 28 29 30
  # dest
  $dest = 'remote', $testconnect = false, $protocol = false, $ssh = false, $port = false,
  $bandwidthlimit = false, $remote_rsync = false, $id_file = false,
  $batch = false, $batchbase = false, $numericids = false, $compress = false,
  $fakesuper = false,
Silvio Rhatto's avatar
Silvio Rhatto committed
31

32 33
  # services
  $initscripts = false, $service = false,
Silvio Rhatto's avatar
Silvio Rhatto committed
34

35 36
  # system
  $rm = false, $cp = false, $touch = false, $mv = false, $fsck = false)
Silvio Rhatto's avatar
Silvio Rhatto committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
{
  include backupninja::client::rsync

  case $dest {
    'remote': {
      case $host { false: { err("need to define a host for remote backups!") } }

      $real_backuptag = $backuptag ? {
          false   => "backupninja-$fqdn",
          default => $backuptag
      }

      $real_home = $home ? {
        false   => "/home/${user}-${name}",
        default => $home,
      }

      $directory = "${real_home}/${subfolder}/"

      backupninja::server::sandbox { "${user}-${name}":
        user                 => $user,
        host                 => $host,
        dir                  => $real_home,
        manage_ssh_dir       => $ssh_dir_manage,
        ssh_dir              => $ssh_dir,
        key                  => $key,
        authorized_keys_file => $authorized_keys_file,
        installuser          => $installuser,
        backuptag            => $real_backuptag,
        keytype              => $backupkeytype,
        backupkeys           => $backupkeystore,
        nagios2_description  => $nagios2_description
      }
     
      backupninja::client::key { "${user}-${name}":
        user       => $user,
        host       => $host,
        installkey => $installkey,
        keytype    => $backupkeytype,
        keystore   => $backupkeystore,
      }
    }
  }

  file { "${backupninja::client::defaults::configdir}/${order}_${name}.rsync":
    ensure  => $ensure,
    content => template('backupninja/rsync.conf.erb'),
    owner   => root,
    group   => root,
    mode    => 0600,
    require => File["${backupninja::client::defaults::configdir}"]
  }
}