Backup Pharos Dashboard Data 31/48431/2
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Wed, 6 Dec 2017 00:36:27 +0000 (16:36 -0800)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Wed, 6 Dec 2017 00:54:21 +0000 (16:54 -0800)
Use an alpine container to mount the pharos_data volume and create a
backup in the home directory on the system.

Change-Id: If6700a8c4cd19a6c4b854efc54225d8f6b973aaa
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
jjb/global/slave-params.yml
jjb/pharos/pharos.yml

index c645de6..ae0ae1e 100644 (file)
           default: $WORKSPACE/build_output
           description: "Directory where the build artifact will be located upon the completion of the build."
 
+- parameter:
+    name: 'pharos-dashboard-defaults'
+    parameters:
+      - label:
+          name: SLAVE_LABEL
+          default: 'pharos-dashboard'
+          description: 'Slave label on Jenkins'
+      - string:
+          name: GIT_BASE
+          default: https://gerrit.opnfv.org/gerrit/$PROJECT
+          description: 'Git URL to use on this Jenkins Slave'
+      - string:
+          name: BUILD_DIRECTORY
+          default: $WORKSPACE/build_output
+          description: "Directory where the build artifact will be located upon the completion of the build."
+
 - parameter:
     name: 'opnfv-build-defaults'
     parameters:
index 7af4f0f..d7067c4 100644 (file)
@@ -12,6 +12,7 @@
 
     jobs:
       - '{project}-verify-{stream}'
+      - 'backup-pharos-dashboard'
 
     stream:
       - master:
     builders:
       - shell: |
           echo "Nothing to verify!"
+
+- job-template:
+    name: 'backup-pharos-dashboard'
+
+    disabled: '{obj:disabled}'
+
+    parameters:
+      - project-parameter:
+          project: 'pharos-tools'
+          branch: 'master'
+      - 'pharos-dashboard-defaults'
+
+    scm:
+      - git-scm-gerrit
+
+    triggers:
+      - timed: '@daily'
+
+    builders:
+      - shell: |
+          mkdir -p /home/backups/
+          DATE=$(date +%Y%m%d)
+          echo "-- $DATE --"
+          echo "Backing up Pharos Dashboard data..."
+          sudo docker run -it --rm \
+            -v pharos_data:/pharos_data:ro \
+            -v /tmp:/backup \
+            alpine \
+            tar -czf /backup/pharos-dashboard-db-$(date +%Y%m%d).tar.gz -C /pharos_data ./
+          sudo mv /tmp/pharos-dashboard-db-$(date +%Y%m%d).tar.gz /home/backups/
+          sudo chown $USER:$USER $WORKSPACE/backups/pharos-dashboard-db-$(date +%Y%m%d).tar.gz
+          echo "...complete"