Browse Source

Add backup command to upgrade

Depends-On: I3ea3cb4342f66da4ead91e945baaddd799522bcf
Change-Id: I95612568b4bcbad52dba95b3275e7465027f3917
changes/92/398592/4
Yuriy Taraday 2 years ago
parent
commit
8ce8211722
2 changed files with 19 additions and 0 deletions
  1. 6
    0
      service/files/backup.sh.j2
  2. 13
    0
      service/upgrade/default.yaml

+ 6
- 0
service/files/backup.sh.j2 View File

@@ -0,0 +1,6 @@
1
+#!/bin/bash -ex
2
+set -o pipefail
3
+BACKUP_FILE="/var/ccp/backup/keystone/backup-$(date "+%Y%m%d%H%M%S").sql"
4
+mysqldump -h {{ address(service.database) }} \
5
+    -u {{ keystone.db.username }} -p{{ keystone.db.password }} \
6
+    --single-transaction {{ keystone.db.name }} > "${BACKUP_FILE}"

+ 13
- 0
service/upgrade/default.yaml View File

@@ -2,6 +2,15 @@ upgrade:
2 2
   name: upgrade-keystone
3 3
   image: keystone
4 4
   steps:
5
+    - name: backup
6
+      command: /opt/ccp/bin/backup.sh
7
+      files:
8
+        - backup-sh
9
+      volumes:
10
+        - name: backup-dir
11
+          path: /var/ccp/backup/keystone
12
+          type: host
13
+          readOnly: false
5 14
     - name: expand
6 15
       files:
7 16
         - keystone-conf
@@ -20,3 +29,7 @@ files:
20 29
   keystone-conf:
21 30
     path: /etc/keystone/keystone.conf
22 31
     content: keystone.conf.j2
32
+  backup-sh:
33
+    path: /opt/ccp/bin/backup.sh
34
+    content: backup.sh.j2
35
+    perm: "500"

Loading…
Cancel
Save