From bee234d0a4e490b0531e1e23488c514dbae7d816 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 11:47:01 -0300 Subject: Initial code for rsync handler --- manifests/rsync.pp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 manifests/rsync.pp (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp new file mode 100644 index 0000000..2839b95 --- /dev/null +++ b/manifests/rsync.pp @@ -0,0 +1,86 @@ +# Run rsync as part of a backupninja run. +# Based on backupninja::rdiff + +define backupninja::rsync( + $order = 90, $ensure = present, $user = false, $home = false, $host = false, + $ssh_dir_manage = true, $ssh_dir = false, $authorized_keys_file = false + $installuser = true, $installkey = true, $key = false, $backuptag = false + $home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, + $nagios2_description = 'backups', $subfolder = 'rsync', + + $rm = false, $cp = false, $touch = false, $mv = false, $fsck = false, + + $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, + + $from = 'local', $rsync = false, $rsync_options = false, + $testconnect = false, $protocol = false, $ssh = false, $port = false, + $bandwidthlimit = false, $remote_rsync = false, $id_file = false, + $batch = false, $filelist = false, $filelistbase = false, + + $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*" ], + + $exclude_vserver = false, $numericids = false, $compress = false, + + $dest = false, $fakesuper = false, $batchname = false, + + $initscripts = false, $service = false) +{ + 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}"] + } +} -- cgit v1.2.3 From 06b5fbe33fabfa97755a840119368440ab258365 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 14:48:38 -0300 Subject: Minor fixes --- manifests/rsync.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp index 2839b95..7d925f2 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -3,8 +3,8 @@ define backupninja::rsync( $order = 90, $ensure = present, $user = false, $home = false, $host = false, - $ssh_dir_manage = true, $ssh_dir = false, $authorized_keys_file = false - $installuser = true, $installkey = true, $key = false, $backuptag = false + $ssh_dir_manage = true, $ssh_dir = false, $authorized_keys_file = false, + $installuser = true, $installkey = true, $key = false, $backuptag = false, $home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, $nagios2_description = 'backups', $subfolder = 'rsync', -- cgit v1.2.3 From c5220c6efb0ae15739c9a78f45a828b19435e31c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 16:50:24 -0300 Subject: Right now just local origin and remote destination is supported --- manifests/rsync.pp | 1 + templates/rsync.conf.erb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp index 7d925f2..bcd1d1b 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -1,5 +1,6 @@ # Run rsync as part of a backupninja run. # Based on backupninja::rdiff +# Right now just local origin and remote destination is supported. define backupninja::rsync( $order = 90, $ensure = present, $user = false, $home = false, $host = false, diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb index 8c61fc8..594683c 100644 --- a/templates/rsync.conf.erb +++ b/templates/rsync.conf.erb @@ -12,7 +12,7 @@ end -%> [source] -<%- %w{from host port user testconnect include exclude ssh protocol rsync rssync_options exclude_vserver, numericids, compress, bandwidthlimit, remote_rsync, id_file, batch, batchbase, filelist, filelistbase}.each do |v| +<%- %w{from testconnect include exclude ssh protocol rsync rssync_options exclude_vserver, numericids, compress, bandwidthlimit, remote_rsync, id_file, batch, batchbase, filelist, filelistbase}.each do |v| if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> <%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- -- cgit v1.2.3 From 06412e03431c2ed125481486d34f6e7efd09f1df Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 21:56:13 -0300 Subject: Right now just local origin and remote destination is supported (2) --- manifests/rsync.pp | 22 ++++++++++++---------- templates/rsync.conf.erb | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp index bcd1d1b..64a42ba 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -9,29 +9,31 @@ define backupninja::rsync( $home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, $nagios2_description = 'backups', $subfolder = 'rsync', - $rm = false, $cp = false, $touch = false, $mv = false, $fsck = false, - + # general $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, - $from = 'local', $rsync = false, $rsync_options = false, - $testconnect = false, $protocol = false, $ssh = false, $port = false, - $bandwidthlimit = false, $remote_rsync = false, $id_file = false, - $batch = false, $filelist = false, $filelistbase = false, - + # source + $from = 'local', $exclude_vserver = false, $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*" ], - $exclude_vserver = false, $numericids = false, $compress = false, + # 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, - $dest = false, $fakesuper = false, $batchname = false, + # services + $initscripts = false, $service = false, - $initscripts = false, $service = false) + # system + $rm = false, $cp = false, $touch = false, $mv = false, $fsck = false) { include backupninja::client::rsync diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb index 594683c..1f0a503 100644 --- a/templates/rsync.conf.erb +++ b/templates/rsync.conf.erb @@ -12,7 +12,7 @@ end -%> [source] -<%- %w{from testconnect include exclude ssh protocol rsync rssync_options exclude_vserver, numericids, compress, bandwidthlimit, remote_rsync, id_file, batch, batchbase, filelist, filelistbase}.each do |v| +<%- %w{from include exclude}.each do |v| if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> <%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- -- cgit v1.2.3 From 3eed9efd2684766ca3d82b1eb354848b6a7e9015 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 22:06:32 -0300 Subject: Removing comments --- manifests/rsync.pp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp index 64a42ba..f973004 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -1,6 +1,5 @@ # Run rsync as part of a backupninja run. # Based on backupninja::rdiff -# Right now just local origin and remote destination is supported. define backupninja::rsync( $order = 90, $ensure = present, $user = false, $home = false, $host = false, @@ -9,34 +8,33 @@ define backupninja::rsync( $home = false, $backupkeytype = "rsa", $backupkeystore = false, $extras = false, $nagios2_description = 'backups', $subfolder = 'rsync', - # general $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, - # source - $from = 'local', $exclude_vserver = false, + $exclude_vserver = false, $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*" ], - # dest - $dest = 'remote', $testconnect = false, $protocol = false, $ssh = false, $port = false, + $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, - # services $initscripts = false, $service = false, - # system $rm = false, $cp = false, $touch = false, $mv = false, $fsck = false) { include backupninja::client::rsync + # Right now just local origin and remote destination is supported. + $from = local + $dest = remote + case $dest { 'remote': { case $host { false: { err("need to define a host for remote backups!") } } -- cgit v1.2.3 From acb2e81dce10fc755601bbd0c3e09cd13f1b1fec Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 16 Aug 2010 22:51:37 -0300 Subject: Minor fixes --- manifests/rsync.pp | 12 ++++++------ templates/rsync.conf.erb | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'manifests/rsync.pp') diff --git a/manifests/rsync.pp b/manifests/rsync.pp index f973004..1c82889 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -9,7 +9,7 @@ define backupninja::rsync( $nagios2_description = 'backups', $subfolder = 'rsync', $log = false, $partition = false, $fscheck = false, $read_only = false, - $mountpoint = false, $backupdir = false, $format = false, $days = '5', + $mountpoint = false, $backupdir = false, $format = false, $days = false, $keepdaily = false, $keepweekly = false, $keepmonthly = false, $lockfile = false, $nicelevel = 0, $enable_mv_timestamp_bug = false, $tmp = false, $multiconnection = false, @@ -31,17 +31,17 @@ define backupninja::rsync( { include backupninja::client::rsync - # Right now just local origin and remote destination is supported. - $from = local - $dest = remote + # Right now just local origin with remote destination is supported. + $from = 'local' + $dest = 'remote' case $dest { 'remote': { case $host { false: { err("need to define a host for remote backups!") } } $real_backuptag = $backuptag ? { - false => "backupninja-$fqdn", - default => $backuptag + false => "backupninja-$fqdn", + default => $backuptag, } $real_home = $home ? { diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb index 1f0a503..71bf0b6 100644 --- a/templates/rsync.conf.erb +++ b/templates/rsync.conf.erb @@ -20,7 +20,7 @@ end -%> end -%> [dest] -<%- %w{dest, testconnect, ssh, protocol, numericids, compress, host, port, user, id_file, bandwidthlimit, remote_rsync, batch, batchbase, fakesuper}.each do |v| +<%- %w{dest testconnect ssh protocol numericids compress host port user id_file bandwidthlimit remote_rsync batch batchbase fakesuper}.each do |v| if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> <%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- @@ -28,7 +28,7 @@ end -%> end -%> [services] -<%- %w{initscripts, service}.each do |v| +<%- %w{initscripts service}.each do |v| if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> <%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- @@ -36,7 +36,7 @@ end -%> end -%> [system] -<%- %w{rm, cp, touch, mv fsck}.each do |v| +<%- %w{rm cp touch mv fsck}.each do |v| if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> <%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- -- cgit v1.2.3