Skip to content

Instantly share code, notes, and snippets.

@thomascate
Created November 13, 2019 23:41
Show Gist options
  • Save thomascate/b29b5ea249da23108d59eed405484c84 to your computer and use it in GitHub Desktop.
Save thomascate/b29b5ea249da23108d59eed405484c84 to your computer and use it in GitHub Desktop.
Chef Automate restore sql
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "backup gz file not provided"
exit 1
fi
echo "restoring $backup_path"
restore_path=$1
PATH=$PATH:$(HAB_LICENSE=accept-no-persist hab pkg path core/postgresql11)/bin
export PATH
source /hab/svc/automate-backend-postgresql/config/functions.sh
# primary_connect_string will always contain the IP of the leader in the cluster
#$(hab pkg path core/gzip)/bin/zcat -c $restore_path | psql ${primary_connect_string} postgres
#cat $restore_path | $(hab pkg path core/gzip)/bin/gunzip | psql ${primary_connect_string} postgres
$(hab pkg path core/gzip)/bin/gunzip < $restore_path | psql ${primary_connect_string} postgres > /dev/null
#psql ${primary_connect_string} postgres < $(hab pkg path core/gzip)/bin/zcat $restore_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment