backup ceph-mon

Change-Id: I62652e2abf67d9ea63ea33a892703b2743767fc3
diff --git a/ceph/backup.sls b/ceph/backup.sls
index 047e7d6..83faf48 100644
--- a/ceph/backup.sls
+++ b/ceph/backup.sls
@@ -74,10 +74,14 @@
   - home: {{ backup.backup_dir }}
 
 {{ backup.backup_dir }}/full:
-    cmd.run:
-      - name: "mkdir -p {{ backup.backup_dir }}/full"
-      - runas: ceph
-      - unless: "test -d {{ backup.backup_dir }}"
+  file.directory:
+  - mode: 755
+  - user: ceph
+  - group: ceph
+  - makedirs: true
+  - require:
+    - user: ceph_user
+    - pkg: ceph_backup_server_packages
 
 {%- for key_name, key in backup.server.key.iteritems() %}
 
diff --git a/ceph/files/backup/ceph-backup-client-runner.sh b/ceph/files/backup/ceph-backup-client-runner.sh
index 56955c3..ca7ba6c 100644
--- a/ceph/files/backup/ceph-backup-client-runner.sh
+++ b/ceph/files/backup/ceph-backup-client-runner.sh
@@ -23,6 +23,13 @@
         exit 1
     fi
 
+    if [ ! -d "$TMPDIR/ceph-$HOSTNAME" ] && [ ! -e "$TMPDIR/ceph-$HOSTNAME" ]; then
+        mkdir -p "$TMPDIR/ceph-$HOSTNAME"
+    else
+        printf "Error creating temporary directory $TMPDIR/ceph-$HOSTNAME"
+        exit 1
+    fi
+
     # Create backup directory.
     if [ ! -d "$BACKUPDIR" ] && [ ! -e "$BACKUPDIR" ]; then
         mkdir -p "$BACKUPDIR"
@@ -35,7 +42,7 @@
 
     cp -a /etc/ceph/ $TMPDIR/
     service ceph-mon@$HOSTNAME stop
-    cp -a /var/lib/ceph/mon/ceph-$HOSTNAME/ $TMPDIR/
+    cp -a /var/lib/ceph/ $TMPDIR/ceph-$HOSTNAME/
     service ceph-mon@$HOSTNAME start
 
     tar -cvzf $BACKUPDIR/$HOSTNAME/ceph-$HOSTNAME-$TIMESTAMP.tgz $TMPDIR
diff --git a/ceph/files/backup/ceph-backup-server-runner.sh b/ceph/files/backup/ceph-backup-server-runner.sh
index 3bcdc4c..3186e8f 100644
--- a/ceph/files/backup/ceph-backup-server-runner.sh
+++ b/ceph/files/backup/ceph-backup-server-runner.sh
@@ -4,7 +4,7 @@
 # Script to erase old backups on ceph 'server role' node.
 # ---------
 
-    BACKUPDIR="{{ backup.remote_backup_dir }}/full"
+    BACKUPDIR="{{ backup.backup_dir }}/full"
     KEEP={{ backup.server.full_backups_to_keep }}
     HOURSFULLBACKUPLIFE={{ backup.server.hours_before_full }} # Lifetime of the latest full backup in seconds
 
diff --git a/metadata/service/backup/client.sls b/metadata/service/backup/client.sls
deleted file mode 100644
index 463bc9a..0000000
--- a/metadata/service/backup/client.sls
+++ /dev/null
@@ -1,11 +0,0 @@
-applications:
-- ceph
-parameters:
-  ceph:
-    backup:
-      client:
-        enabled: true
-        full_backups_to_keep: 3
-        hours_before_full: 24
-        # target:
-        #   host: cfg01
diff --git a/metadata/service/backup/client.yml b/metadata/service/backup/client.yml
new file mode 100644
index 0000000..2c1b1fc
--- /dev/null
+++ b/metadata/service/backup/client.yml
@@ -0,0 +1,13 @@
+applications:
+- ceph
+parameters:
+  _param:
+    ceph_remote_backup_server: cfg01
+  ceph:
+    backup:
+      client:
+        enabled: true
+        full_backups_to_keep: 3
+        hours_before_full: 24
+        target:
+          host: ${_param:ceph_remote_backup_server}
diff --git a/metadata/service/backup/server.sls b/metadata/service/backup/server.sls
deleted file mode 100644
index 181101e..0000000
--- a/metadata/service/backup/server.sls
+++ /dev/null
@@ -1,13 +0,0 @@
-applications:
-- ceph
-parameters:
-  ceph:
-    backup:
-      server:
-        enabled: true
-        hours_before_full: 24
-        full_backups_to_keep: 5
-        key:
-          ceph_pub_key:
-            enabled: true
-            key: ssh_rsa
diff --git a/metadata/service/backup/server.yml b/metadata/service/backup/server.yml
new file mode 100644
index 0000000..937e13d
--- /dev/null
+++ b/metadata/service/backup/server.yml
@@ -0,0 +1,15 @@
+applications:
+- ceph
+parameters:
+  _param:
+    ceph_backup_public_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzLUiHKAjfFXiZ3fsgx35uXF6VivfC5WFafu4QMalxmj6W+s277oCfdWA8Du5f1wtQXM73VQ5nHkXhM2UIfUMarsyhXK+BxKVrcgEBNHdKlDytaecUPyuOxTDdGWhN/DPv5/vL8NYWweEYBbNbLgU0Td7Rvm52TUXKThIDjeF7XDxX4ShXWipBSwU4boOUBtR8KWfga8fsqeBN+eacuAQFR3MrrOfVvAuWW6Bsf047cmd+V6Qv0raoW73Nu4M/ZAdTsaR5k62a0cHsSRoi3hCmNRqw+CZaQi8prQU6t26eWPEtznjp5EkPF+LLh8LxUoCfWqWT+Lxe8QQwT1nx/LCN
+  ceph:
+    backup:
+      server:
+        enabled: true
+        hours_before_full: 24
+        full_backups_to_keep: 5
+        key:
+          ceph_pub_key:
+            enabled: true
+            key: ${_param:ceph_backup_public_key}