Merge "[docker] Use image IDs instead of tags"
[releng.git] / jjb / releng / testapi-backup-mongodb.sh
1 #!/bin/bash
2
3 set -e
4
5 # Run MongoDB backup
6 python $WORKSPACE/utils/test/testapi/update/templates/backup_mongodb.py -o $WORKSPACE/
7
8 # Compressing the dump
9 now=$(date +"%m_%d_%Y_%H_%M_%S")
10 echo $now
11
12 file_name="testapi_mongodb_"$now".tar.gz"
13 echo $file_name
14
15 tar cvfz "$file_name" test_results_collection*
16
17 rm -rf test_results_collection*
18
19 artifact_dir="testapibackup"
20 workspace="$WORKSPACE"
21
22 set +e
23 /usr/local/bin/gsutil &>/dev/null
24 if [ $? != 0 ]; then
25     echo "Not possible to push results to artifact: gsutil not installed"
26     exit 1
27 else
28     echo "Uploading mongodump to artifact $artifact_dir"
29     /usr/local/bin/gsutil cp -r "$workspace"/"$file_name" gs://artifacts.opnfv.org/"$artifact_dir"/
30     echo "MongoDump can be found at http://artifacts.opnfv.org/$artifact_dir.html"
31 fi