summaryrefslogtreecommitdiffstats
path: root/utils/test/result_collection_api/tools/backup-db.sh
blob: 8d12a6fc7efb0421195eb9c9d0df718a0b66951a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

echo "Backup Test collection DB"
now=$(date +"%m_%d_%Y_%H_%M_%S")
echo $now
echo " ------------- "
TARGET_DIR=./$now
TEST_RESULT_DB_BACKUP="test_collection_db."$now".tar.gz"

echo "Create Directory for backup"
mkdir -p $TARGET_DIR

echo "Export results"
mongoexport -db test_results_collection -c test_results --out $TARGET_DIR/results.json
echo "Export test cases"
mongoexport --db test_results_collection -c test_cases --out $TARGET_DIR/backup-cases.json
echo "Export projects"
mongoexport --db test_results_collection -c test_projects --out $TARGET_DIR/backup-projects.json
echo "Export pods"
mongoexport --db test_results_collection -c pod --out $TARGET_DIR/backup-pod.json

echo "Create tar.gz"
tar -cvzf $TEST_RESULT_DB_BACKUP $TARGET_DIR

echo "Delete temp directory"
rm -Rf $TARGET_DIR