aa36aa370671d31ad81dfba1f58f216d6873a787
[releng.git] / utils / test / scripts / backup-db.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Orange and others.
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 echo "Backup Test collection DB"
11 now=$(date +"%m_%d_%Y_%H_%M_%S")
12 echo $now
13 echo " ------------- "
14 TARGET_DIR=./$now
15 TEST_RESULT_DB_BACKUP="test_collection_db."$now".tar.gz"
16
17 echo "Create Directory for backup"
18 mkdir -p $TARGET_DIR
19
20 echo "Export results"
21 mongoexport -db test_results_collection -c test_results --out $TARGET_DIR/results.json
22 echo "Export test cases"
23 mongoexport --db test_results_collection -c test_cases --out $TARGET_DIR/backup-cases.json
24 echo "Export projects"
25 mongoexport --db test_results_collection -c test_projects --out $TARGET_DIR/backup-projects.json
26 echo "Export pods"
27 mongoexport --db test_results_collection -c pod --out $TARGET_DIR/backup-pod.json
28
29 echo "Create tar.gz"
30 tar -cvzf $TEST_RESULT_DB_BACKUP $TARGET_DIR
31
32 echo "Delete temp directory"
33 rm -Rf $TARGET_DIR