equal
deleted
inserted
replaced
|
1 #!/usr/bin/env bash |
|
2 |
|
3 SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
|
4 SCRIPTNAME=`basename "$0"` |
|
5 |
|
6 usage() { |
|
7 echo -n "${SCRIPTNAME} [CONFIG] [DB_FILE_PATH] |
|
8 |
|
9 Dump the database to <DB_FILE_PATH> using ansible. |
|
10 Beware this will replace the dest file without warning |
|
11 " |
|
12 } |
|
13 |
|
14 if [[ "$#" -ne 2 ]]; then |
|
15 usage |
|
16 exit 1 |
|
17 fi |
|
18 |
|
19 config=${1} |
|
20 db_file_path=${2} |
|
21 |
|
22 case $config in |
|
23 test) configOK=true;; |
|
24 prod) configOK=true;; |
|
25 *) configOK=false;; |
|
26 esac |
|
27 |
|
28 if [[ "$configOK" = false ]]; then |
|
29 usage |
|
30 exit 1 |
|
31 fi |
|
32 |
|
33 pushd "$SCRIPTPATH" |
|
34 |
|
35 ANSIBLE_SSH_PIPELINING=1 ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -v -i "./hosts/hosts.$config" -l "$config" ./dump_db.yml --extra-vars "db_file_path='${db_file_path}'" --ask-vault-pass |
|
36 |
|
37 popd |