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 --- templates/rsync.conf.erb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 templates/rsync.conf.erb (limited to 'templates/rsync.conf.erb') diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb new file mode 100644 index 0000000..8c61fc8 --- /dev/null +++ b/templates/rsync.conf.erb @@ -0,0 +1,44 @@ +# 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. + +[general] +<%- %w{log partition fscheck read_only mountpoint backupdir format days keepdaily keepweekly keepmonthly lockfile nicelevel enable_mv_timestamp_bug, tmp, multiconnection}.each do |v| + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + ' = ' + instance_variable_get("@#{v}").to_s %> +<%- + end +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| + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + ' = ' + instance_variable_get("@#{v}").to_s %> +<%- + end +end -%> + +[dest] +<%- %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 %> +<%- + end +end -%> + +[services] +<%- %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 %> +<%- + end +end -%> + +[system] +<%- %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 %> +<%- + end +end -%> -- 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 'templates/rsync.conf.erb') 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 'templates/rsync.conf.erb') 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 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 'templates/rsync.conf.erb') 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 From 018f03e5fdcfe433acb34a143599fca3dfbffc33 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 22 Jan 2013 12:22:40 -0200 Subject: Fixing handling for include and exclude parameters as arrays at rsync template --- templates/rsync.conf.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'templates/rsync.conf.erb') diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb index 71bf0b6..163ffc3 100644 --- a/templates/rsync.conf.erb +++ b/templates/rsync.conf.erb @@ -12,9 +12,13 @@ end -%> [source] -<%- %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 %> +<% unless from.empty? and from.to_s != "false" -%> +from = <%= from %> +<% end -%> +<%- %w{include exclude}.each do |v| + if has_variable?(v) + instance_variable_get("@#{v}").to_a.each do |parameter| -%> +<%= v + ' = ' + parameter %> <%- end end -%> -- cgit v1.2.3 From b4657888b560aed7885d2a9248bdb00604976257 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 22 Jan 2013 12:24:49 -0200 Subject: Fixing handling for include and exclude parameters as arrays at rsync template (2) --- templates/rsync.conf.erb | 1 + 1 file changed, 1 insertion(+) (limited to 'templates/rsync.conf.erb') diff --git a/templates/rsync.conf.erb b/templates/rsync.conf.erb index 163ffc3..778676f 100644 --- a/templates/rsync.conf.erb +++ b/templates/rsync.conf.erb @@ -20,6 +20,7 @@ from = <%= from %> instance_variable_get("@#{v}").to_a.each do |parameter| -%> <%= v + ' = ' + parameter %> <%- + end end end -%> -- cgit v1.2.3