diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2016-09-29 13:51:44 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2016-09-29 13:51:44 +0300 |
commit | 62f28d30a069135f9c48678507203958adfc334f (patch) | |
tree | 7f38af0c8d3f445ee8cc50906a639baec7011127 /pkgs/rdsdump | |
parent | 1af9e6589bdd18e6ba7eeabf073aa7d710020cdd (diff) | |
download | nixsap-62f28d30a069135f9c48678507203958adfc334f.tar.gz |
Moved everything into ./modules
Diffstat (limited to 'pkgs/rdsdump')
-rw-r--r-- | pkgs/rdsdump/default.nix | 14 | ||||
-rw-r--r-- | pkgs/rdsdump/rdsdump.bash | 70 |
2 files changed, 0 insertions, 84 deletions
diff --git a/pkgs/rdsdump/default.nix b/pkgs/rdsdump/default.nix deleted file mode 100644 index 0efe033..0000000 --- a/pkgs/rdsdump/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ stdenv, bash, ... }: - -stdenv.mkDerivation { - name = "rdsdump"; - buildInputs = [ bash ]; - phases = [ "installPhase" ]; - installPhase = '' - mkdir -p $out/bin - cp -a ${./rdsdump.bash} $out/bin/rdsdump - chmod +x $out/bin/rdsdump - patchShebangs $out/bin/rdsdump - ''; -} - diff --git a/pkgs/rdsdump/rdsdump.bash b/pkgs/rdsdump/rdsdump.bash deleted file mode 100644 index 6b8cbf1..0000000 --- a/pkgs/rdsdump/rdsdump.bash +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -mysql_args= -mysqldump_args= -master_data=0 -while [ $# -gt 0 ]; do - case $1 in - --host=*|--password=*|--user=*|\ - --defaults-file=*|--defaults-extra-file=*|\ - --ssl=*|--ssl-ca=*|--ssl-key=*|--ssl-cert=*|\ - -h?*|-u?*|-p?*) - mysql_args="$mysql_args $1" - mysqldump_args="$mysqldump_args $1" - shift 1;; - --host|--user|\ - --defaults-file|--defaults-extra-file|\ - --ssl-ca|--ssl-key|--ssl-cert|\ - -h|-u) - mysql_args="$mysql_args $1 $2" - mysqldump_args="$mysqldump_args $1 $2" - shift 2;; - --master-data=*) - master_data=$(echo "$1" | cut -d= -f2) - shift;; - --master-data) - master_data=$2 - shift 2;; - *) - mysqldump_args="$mysqldump_args $1" - shift;; - esac -done - -replica () { - mysql $mysql_args "$@" -} - -start_replication () { - replica -N -e "CALL mysql.rds_start_replication;" >&2 -} - -stop_replication () { - replica -N -e "CALL mysql.rds_stop_replication;" >&2 -} - -trap 'start_replication' EXIT -stop_replication - -if [ "$master_data" -gt 0 ]; then -if [ "$master_data" -eq 2 ]; then - printf '-- ' -fi -replica -e 'SHOW SLAVE STATUS\G' | awk -f <(cat - <<- 'AWK' - /\<Exec_Master_Log_Pos\>/ { log_pos = $2 }; - /\<Relay_Master_Log_File\>/ { log_file = $2 }; - END { - printf "CHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%d;\n", log_file, log_pos - } -AWK -) -fi - -mysqldump $mysqldump_args & -sleep 30 - -start_replication -trap - EXIT - -wait |