Created
April 16, 2020 12:56
-
-
Save remyd1/035870cc2322ca3ae3e979e968d36d44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
password=`awk '{ if ( $1 == "password:" ) {print $2;} }' lemmy.hjson |tr -d '"'` | |
host=`awk '{ if ( $1 == "host:" ) {print $2;} }' lemmy.hjson |tr -d '"'` | |
username=`awk '{ if ( $1 == "user:" ) {print $2;} }' lemmy.hjson |tr -d '"'` | |
database=`awk '{ if ( $1 == "database:" ) {print $2;} }' lemmy.hjson` | |
port=`awk '{ if ( $1 == "port:" ) {print $2;} }' lemmy.hjson |head -1` | |
#echo "pass: "${password} | |
database=`echo $database |tr -d '"' |tr -d " {"` | |
echo "${host}:${port}:${database}:${username}:${password}" > .pgpass | |
# writing pass to .pgpasse for lemmy PG container | |
docker cp .pgpass lemmy_${host}_1:/root/.pgpass | |
docker exec -it lemmy_${host}_1 chmod 0600 /root/.pgpass | |
docker exec -it lemmy_${host}_1 pg_dumpall -c -U lemmy > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment