Skip to content

Instantly share code, notes, and snippets.

@remyd1
Created April 16, 2020 12:56
Show Gist options
  • Save remyd1/035870cc2322ca3ae3e979e968d36d44 to your computer and use it in GitHub Desktop.
Save remyd1/035870cc2322ca3ae3e979e968d36d44 to your computer and use it in GitHub Desktop.
#!/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