8d12a6fc7efb0421195eb9c9d0df718a0b66951a
[releng.git] / utils / test / result_collection_api / tools / backup-db.sh
1 #!/bin/bash
2
3 echo "Backup Test collection DB"
4 now=$(date +"%m_%d_%Y_%H_%M_%S")
5 echo $now
6 echo " ------------- "
7 TARGET_DIR=./$now
8 TEST_RESULT_DB_BACKUP="test_collection_db."$now".tar.gz"
9
10 echo "Create Directory for backup"
11 mkdir -p $TARGET_DIR
12
13 echo "Export results"
14 mongoexport -db test_results_collection -c test_results --out $TARGET_DIR/results.json
15 echo "Export test cases"
16 mongoexport --db test_results_collection -c test_cases --out $TARGET_DIR/backup-cases.json
17 echo "Export projects"
18 mongoexport --db test_results_collection -c test_projects --out $TARGET_DIR/backup-projects.json
19 echo "Export pods"
20 mongoexport --db test_results_collection -c pod --out $TARGET_DIR/backup-pod.json
21
22 echo "Create tar.gz"
23 tar -cvzf $TEST_RESULT_DB_BACKUP $TARGET_DIR
24
25 echo "Delete temp directory"
26 rm -Rf $TARGET_DIR