One dup/rdiff/rsync file for all fs_include
diff --git a/backupninja/client.sls b/backupninja/client.sls
index abcc70e..0c757c4 100644
--- a/backupninja/client.sls
+++ b/backupninja/client.sls
@@ -60,16 +60,6 @@
- makedirs: true
- user: root
-{%- set service_grains = {'backupninja': {'backup': {}}} %}
-{%- for service_name, service in pillar.items() %}
-{%- if service.get('_support', {}).get('backupninja', {}).get('enabled', False) %}
-{%- set grains_fragment_file = service_name+'/meta/backupninja.yml' %}
-{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
-{%- set grains_yaml = load_grains_file()|load_yaml %}
-{%- set _dummy = service_grains.backupninja.backup.update(grains_yaml.backup) %}
-{%- endif %}
-{%- endfor %}
-
backupninja_client_grain:
file.managed:
- name: /etc/salt/grains.d/backupninja
@@ -77,8 +67,6 @@
- template: jinja
- user: root
- mode: 600
- - defaults:
- service_grains: {{ service_grains|yaml }}
- require:
- file: backupninja_client_grains_dir
@@ -104,20 +92,14 @@
- require:
- pkg: backupninja_packages
-{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
-{%- if backup.fs_includes is defined %}
-backupninja_remote_handler_{{ backup_name }}:
+backupninja_remote_handler_{{ client.target.engine }}:
file.managed:
- - name: /etc/backup.d/200.{{ backup_name }}.{{ client.target.engine }}
+ - name: /etc/backup.d/200.backup.{{ client.target.engine }}
- source: salt://backupninja/files/{{ client.target.engine }}.conf
- template: jinja
- mode: 600
- - defaults:
- backup: {{ backup }}
- require:
- pkg: backupninja_packages
-{%- endif %}
-{%- endfor %}
{%- if client.target.auth.gss is defined %}
backupninja_gss_helper_kinit:
diff --git a/backupninja/files/backupninja.grain b/backupninja/files/backupninja.grain
index 3e3b373..6345ff0 100644
--- a/backupninja/files/backupninja.grain
+++ b/backupninja/files/backupninja.grain
@@ -1 +1,2 @@
+{%- from "backupninja/map.jinja" import service_grains with context -%}
{{ service_grains|yaml(False) }}
diff --git a/backupninja/files/dup.conf b/backupninja/files/dup.conf
index e57e9bf..dbc633d 100644
--- a/backupninja/files/dup.conf
+++ b/backupninja/files/dup.conf
@@ -1,5 +1,4 @@
-{%- from "backupninja/map.jinja" import client with context %}
-{%- from "linux/map.jinja" import system with context %}
+{%- from "backupninja/map.jinja" import client, service_grains with context -%}
## This is an example duplicity configuration file.
##
## Here you can find all the possible duplicity options, details of
@@ -110,10 +109,11 @@
## taken into account.
## files to include in the backup
-
-{%- for fs_include in backup.fs_includes %}
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+{%- for fs_include in backup.get('fs_includes', []) %}
include = {{ fs_include }}
{%- endfor %}
+{%- endfor %}
## If vservers = yes in /etc/backupninja.conf then the following variables can
## be used:
@@ -131,9 +131,11 @@
## Vservers paths are derived from $VROOTDIR.
# files to exclude from the backup
-{%- for fs_exclude in backup.fs_excludes %}
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+{%- for fs_exclude in backup.get('fs_excludes', []) %}
exclude = {{ fs_exclude }}
{%- endfor %}
+{%- endfor %}
######################################################
diff --git a/backupninja/files/rdiff.conf b/backupninja/files/rdiff.conf
index b2f4853..08fc92e 100644
--- a/backupninja/files/rdiff.conf
+++ b/backupninja/files/rdiff.conf
@@ -97,9 +97,11 @@
## taken into account.
## files to include in the backup
-{%- for fs_include in backup.fs_includes %}
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+{%- for fs_include in backup.get('fs_includes', []) %}
include = {{ fs_include }}
{%- endfor %}
+{%- endfor %}
## If vservers = yes in /etc/backupninja.conf then the following variables can
## be used:
@@ -116,9 +118,11 @@
## and /vservers/baz/home.
## Vservers paths are derived from $VROOTDIR.
-{%- for fs_exclude in backup.fs_excludes %}
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+{%- for fs_exclude in backup.get('fs_excludes', []) %}
exclude = {{ fs_exclude }}
{%- endfor %}
+{%- endfor %}
######################################################
diff --git a/backupninja/files/rsync.conf b/backupninja/files/rsync.conf
index 3c4eb97..e5d8126 100644
--- a/backupninja/files/rsync.conf
+++ b/backupninja/files/rsync.conf
@@ -101,7 +101,9 @@
# when "yes", test the connection for a remote source before backup
#testconnect = no
-{%- for fs_include in backup.fs_includes %}
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+
+{%- for fs_include in backup.get('fs_includes', []) %}
include = {{ fs_include }}
{%- endfor %}
@@ -109,6 +111,8 @@
exclude = {{ fs_exclude }}
{%- endfor %}
+{%- endfor %}
+
# exlude some vserver from backup
# this is used only if vservers = yes on backupninja.conf
#exclude_vserver = excluded_vserver1
@@ -195,7 +199,7 @@
# remote rsync program (remote dest only)
{%- if grains.os == 'Ubuntu' and grains.osrelease >= '14.04' %}
-remote_rsync = '{% for fs_include in backup.fs_includes %} mkdir -p /srv/backupninja/{{ network.fqdn }}{{ fs_include }} && {% endfor %} rsync'
+remote_rsync = '{% for backup_name, backup in service_grains.backupninja.backup.iteritems() %}{% for fs_include in backup.get('fs_includes', []) %}mkdir -p /srv/backupninja/{{ network.fqdn }}{{ fs_include }};{% endfor %}{% endfor %} rsync'
{%- else %}
#remote_rsync = rsync
{%- endif %}
diff --git a/backupninja/map.jinja b/backupninja/map.jinja
index bab9434..d63dbe6 100644
--- a/backupninja/map.jinja
+++ b/backupninja/map.jinja
@@ -28,3 +28,13 @@
'keys': [],
},
}, merge=salt['pillar.get']('backupninja:server')) %}
+
+{%- set service_grains = {'backupninja': {'backup': {}}} %}
+{%- for service_name, service in pillar.items() %}
+{%- if service.get('_support', {}).get('backupninja', {}).get('enabled', False) %}
+{%- set grains_fragment_file = service_name+'/meta/backupninja.yml' %}
+{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
+{%- set grains_yaml = load_grains_file()|load_yaml %}
+{%- set _dummy = service_grains.backupninja.backup.update(grains_yaml.backup) %}
+{%- endif %}
+{%- endfor %}