Update Pharos Dashboard Jobs
[releng.git] / jjb / pharos / shell / backup-dashboard.sh
1 #!/bin/bash -eux
2 ##############################################################################
3 # Copyright (c) 2018 Linux Foundation and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 BACKUP_DIR=$HOME/backups
12 DATE=$(date +%Y%m%d)
13 TAR_FILE=pharos-dashboard-db-$DATE.tar.tz
14
15 mkdir -p $BACKUP_DIR
16 echo "-- $DATE --"
17 echo "--> Backing up Pharos Dashboard"
18
19 docker run --rm \
20   -v pharos-data:/pharos-data:ro \
21   -v $BACKUP_DIR:/backup \
22   alpine \
23   tar -czf /backup/$TAR_FILE -C /pharos-data ./
24
25 /usr/local/bin/gsutil cp $BACKUP_DIR/$TAR_FILE \
26   gs://opnfv-backups/pharos-dashboard/ && rm $BACKUP_DIR/$TAR_FILE
27
28 echo "--> Pharos dashboard backup complete"