diff --git a/greenlight-dbshell b/greenlight-dbshell new file mode 100755 index 0000000000000000000000000000000000000000..da3e181be5f31f860ff8af3475fe7a29e67a41ce --- /dev/null +++ b/greenlight-dbshell @@ -0,0 +1,2 @@ +#!/bin/sh +docker exec -itu postgres greenlight_db_1 psql $* diff --git a/greenlight-postgres-backup-greenlight-only b/greenlight-postgres-backup-greenlight-only new file mode 100755 index 0000000000000000000000000000000000000000..8fc90c6007fcf2d349b63d1133b4aa6ff85ed850 --- /dev/null +++ b/greenlight-postgres-backup-greenlight-only @@ -0,0 +1,24 @@ +#!/bin/bash +# backup the greenlight postgres dbs +# (c) 2020-2038 cc-by-nc-sa wotwot + +now=`date +%Y%m%d-%H%M` +host=`hostname -s` +file="postgres-${host}-${now}-greenlight-only.sql" +dir="/var/backups/postgresql" +dbname="greenlight_db_1" + +if [ ! -d "$dir" ] ; then + echo "no $dir, making one" + mkdir $dir +fi + +cd /root/greenlight || \ + { + echo "greenlight not found" + exit + } + +#docker ps || exit + +docker exec -u postgres ${dbname} pg_dump greenlight_production -c > ${dir}/${file} diff --git a/greenlight-postgres-backup-greenlight-only.nop b/greenlight-postgres-backup-greenlight-only.nop new file mode 100755 index 0000000000000000000000000000000000000000..4086c01598acac7a66e3f873ce2ae3ed50d363e4 --- /dev/null +++ b/greenlight-postgres-backup-greenlight-only.nop @@ -0,0 +1,25 @@ +#!/bin/bash +# backup the greenlight postgres dbs +# (c) 2020-2038 cc-by-nc-sa wotwot + +now=`date +%Y%m%d-%H%M` +host=`hostname -s` +file="postgres-${host}-${now}-greenlight-only.sql" +dir="/var/backups/postgresql" +dbname="greenlight_db_1" + +if [ ! -d "$dir" ] ; then + echo "no $dir, making one" + mkdir $dir +fi + +cd /root/greenlight || \ + { + echo "greenlight not found" + exit + } + +#docker ps || exit + +docker exec -u postgres ${dbname} pg_dumpall > ${dir}/${file} +docker exec -u postgres ${dbname} pg_dump greenlight_production > ${dir}/${file} diff --git a/greenlight-postgres-restore-all b/greenlight-postgres-restore-all new file mode 100755 index 0000000000000000000000000000000000000000..95a017a839233008a4f634be6fea24f713b64d33 --- /dev/null +++ b/greenlight-postgres-restore-all @@ -0,0 +1,9 @@ +#!/bin/sh +file=$* +if [ -z "$file" ] ; then + echo "ouch wot ?" + exit +fi +# docker exec -u postgres greenlight_db_1 psql postgres < ../bbb-postgres-20200514.sql +# docker exec -u postgres greenlight_db_1 psql greenlight_production < ../bbb-greenlight_production-20200514.sql +docker exec -u postgres greenlight_db_1 psql < $file diff --git a/greenlight-postgres-restore-greenlight-only b/greenlight-postgres-restore-greenlight-only new file mode 100755 index 0000000000000000000000000000000000000000..64a8e07e70caffee4af0d9c6f7880e7bc5342092 --- /dev/null +++ b/greenlight-postgres-restore-greenlight-only @@ -0,0 +1,27 @@ +#!/bin/bash +# restore a greenlight postgres db from a textdump +# (c) 2020-2038 cc-by-nc-sa wotwot + +file=$1 + +if [ -z "$file" ] ; then + echo "nah. tell me the full path to the file to replace the greenlight db with" > /dev/stderr + exit +else + if [ ! -f "$file" ] ; then + echo "file not found" > /dev/stderr + exit + fi +fi + +dbname="greenlight_db_1" + +cd /root/greenlight || \ + { + echo "greenlight not found" + exit + } + +echo "docker exec -u postgres ${dbname} psql greenlight_production < $file" +docker exec -u postgres ${dbname} psql greenlight_production < $file + diff --git a/greenlight-rails-shell b/greenlight-rails-shell new file mode 100755 index 0000000000000000000000000000000000000000..8aade0cfdb148edeabee08ea884603aa49b1ea59 --- /dev/null +++ b/greenlight-rails-shell @@ -0,0 +1,2 @@ +#!/bin/sh +docker exec -it greenlight-v2 bash