fixes
diff --git a/backupninja/client.sls b/backupninja/client.sls
index 624ac05..809508d 100644
--- a/backupninja/client.sls
+++ b/backupninja/client.sls
@@ -47,24 +47,49 @@
{%- endif %}
+backupninja_client_grains_dir:
+ file.directory:
+ - name: /etc/salt/grains.d
+ - mode: 700
+ - 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
+ - source: salt://backupninja/files/backupninja.grain
+ - template: jinja
+ - user: root
+ - mode: 600
+ - defaults:
+ service_grains: {{ service_grains|yaml }}
+ - require:
+ - file: backupninja_client_grains_dir
+
{%- if client.target is defined %}
{%- if client.target.engine in ["s3",] %}
-
backupninja_duplicity_packages:
pkg.installed:
- names:
- duplicity
-
{%- endif %}
{%- if client.target.engine in ["rdiff",] %}
-
backupninja_duplicity_packages:
pkg.installed:
- names:
- rdiff-backup
-
{%- endif %}
backupninja_remote_handler:
@@ -73,34 +98,21 @@
- require:
- pkg: backupninja_packages
-{%- for service in client.supported_services %}
-{%- if service in grains.get('roles', []) %}
-
-{%- for service_group in service.split('.') %}
-{%- if loop.first %}
-
-backupninja_remote_handler_{{ service|replace('.', '_') }}:
+{%- for backup_name, backup in service_grains.backupninja.backup.iteritems() %}
+{%- if backup.fs_include is defined %}
+backupninja_remote_handler_{{ backup_name }}:
file.managed:
- - name: /etc/backup.d/20{{ loop.index }}.{{ service_group }}.{{ client.target.engine }}
+ - name: /etc/backup.d/200.{{ backup_name }}.{{ client.target.engine }}
- source: salt://backupninja/files/{{ client.target.engine }}.conf
- template: jinja
- mode: 600
- defaults:
- service_config: {{ service_group }}/files/backupninja.conf
- {%- if client.config_monkeypatch is defined and client.config_monkeypatch %}
- {%- if service in client.monkey_patched %}
- service_config_monkeypatch: {{ service_group }}/files/backupninja_monkeypatch.conf
- {%- endif %}
- {%- endif %}
+ backup: {{ backup }}
- require:
- pkg: backupninja_packages
-
{%- endif %}
{%- endfor %}
{%- endif %}
-{%- endfor %}
{%- endif %}
-
-{%- endif %}
\ No newline at end of file
diff --git a/backupninja/files/backupninja.grain b/backupninja/files/backupninja.grain
new file mode 100644
index 0000000..3e3b373
--- /dev/null
+++ b/backupninja/files/backupninja.grain
@@ -0,0 +1 @@
+{{ service_grains|yaml(False) }}
diff --git a/backupninja/files/dup.conf b/backupninja/files/dup.conf
index 0a8d0bb..ea9bf17 100644
--- a/backupninja/files/dup.conf
+++ b/backupninja/files/dup.conf
@@ -110,15 +110,10 @@
## taken into account.
## files to include in the backup
-include = /var/spool/cron/crontabs
-include = /var/backups
-include = /etc
-include = /root
-include = /home
-include = /usr/local/bin
-include = /usr/local/sbin
-include = /var/lib/dpkg/status
-include = /var/lib/dpkg/status-old
+
+{%- for fs_include in backup.fs_includes %}
+include = {{ fs_include }}
+{%- endfor %}
## If vservers = yes in /etc/backupninja.conf then the following variables can
## be used:
@@ -136,8 +131,10 @@
## Vservers paths are derived from $VROOTDIR.
# files to exclude from the backup
-exclude = /home/*/.gnupg
-exclude = /var/cache/backupninja/duplicity
+{%- for fs_exclude in backup.fs_excludes %}
+exclude = {{ fs_exclude }}
+{%- endfor %}
+
######################################################
## destination section
diff --git a/backupninja/files/rdiff.conf b/backupninja/files/rdiff.conf
index 1f41861..b2f4853 100644
--- a/backupninja/files/rdiff.conf
+++ b/backupninja/files/rdiff.conf
@@ -97,15 +97,9 @@
## taken into account.
## files to include in the backup
-include = /var/spool/cron/crontabs
-include = /var/backups
-include = /etc
-include = /root
-include = /home
-include = /usr/local/bin
-include = /usr/local/sbin
-include = /var/lib/dpkg/status
-include = /var/lib/dpkg/status-old
+{%- for fs_include in backup.fs_includes %}
+include = {{ fs_include }}
+{%- endfor %}
## If vservers = yes in /etc/backupninja.conf then the following variables can
## be used:
@@ -122,9 +116,10 @@
## and /vservers/baz/home.
## Vservers paths are derived from $VROOTDIR.
-## files to exclude from the backup
-exclude = /home/*/.gnupg
-exclude = /var/cache/backupninja/duplicity
+{%- for fs_exclude in backup.fs_excludes %}
+exclude = {{ fs_exclude }}
+{%- endfor %}
+
######################################################
## destination section
diff --git a/backupninja/files/rsync.conf b/backupninja/files/rsync.conf
index def0e5b..eb35288 100644
--- a/backupninja/files/rsync.conf
+++ b/backupninja/files/rsync.conf
@@ -100,7 +100,13 @@
# when "yes", test the connection for a remote source before backup
#testconnect = no
-{% include service_config %}
+{%- for fs_include in backup.fs_includes %}
+include = {{ fs_include }}
+{%- endfor %}
+
+{%- for fs_exclude in backup.fs_excludes %}
+exclude = {{ fs_exclude }}
+{%- endfor %}
# exlude some vserver from backup
# this is used only if vservers = yes on backupninja.conf
@@ -228,7 +234,3 @@
#
# fsck command
#fsck = fsck
-
-{%- if service_config_monkeypatch is defined %}
-{% include service_config_monkeypatch %}
-{%- endif %}
\ No newline at end of file
diff --git a/backupninja/init.sls b/backupninja/init.sls
index a2f94d7..b04e54b 100644
--- a/backupninja/init.sls
+++ b/backupninja/init.sls
@@ -1,4 +1,3 @@
-
{%- if pillar.backupninja is defined %}
include:
{%- if pillar.backupninja.client is defined %}
diff --git a/backupninja/map.jinja b/backupninja/map.jinja
index 75f18da..0fe79ba 100644
--- a/backupninja/map.jinja
+++ b/backupninja/map.jinja
@@ -9,10 +9,12 @@
'taiga.server',
'webcms.server',
] %}
+
{% set monkey_patched = [
'leonardo.server',
'postgresql.server',
] %}
+
{%- if grains.osrelease >= '14.04' %}
{% set config_monkeypatch = True %}
{%- else %}
diff --git a/metadata/service/client/init.yml b/metadata/service/client/init.yml
index 37c3106..b4f71fc 100644
--- a/metadata/service/client/init.yml
+++ b/metadata/service/client/init.yml
@@ -9,4 +9,4 @@
target:
engine: rsync
host: ${_param:backupninja_target_host}
- user: backupninja
\ No newline at end of file
+ user: backupninja