X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=buster%2Fsetup_scripts%2Frestore_app.sh;h=363a5f6edb4c859d7e81532ee317322b3a1fc270;hb=f1901562e5d3859b4e9a9eb7c5f48c6db73fc8b1;hp=cb307883bcebd7275395878c29c8c2085c51f052;hpb=19bd8ce75275c6d6d737dbdf78ab3d969369b19f;p=config diff --git a/buster/setup_scripts/restore_app.sh b/buster/setup_scripts/restore_app.sh index cb30788..363a5f6 100755 --- a/buster/setup_scripts/restore_app.sh +++ b/buster/setup_scripts/restore_app.sh @@ -6,8 +6,8 @@ if [ "$#" -lt 2 ]; then echo 'Need two arguments: service name and DB name.' false fi -if [ ! "$1" = "pleroma" ] && [ ! "$1" = "peertube" ]; then - echo "Need legal service name (pleroma or peertube)." +if [ ! "$1" = "pleroma_otp" ] && [ ! "$1" = "pleroma_sourc" ] && [ ! "$1" = "peertube" ]; then + echo "Need legal service name (pleroma_otp or pleroma_source or peertube)." false fi app="$1" @@ -19,11 +19,16 @@ mv "/home/plom/${app}_backup.tar" /tmp/ cd /tmp tar xf "${app}_backup.tar" -su postgres -c "pg_restore -c -C -d ${db_name} -1 ${app}_backup/${db_name}.pgdump" +su postgres -c "pg_restore -c -1 -d ${db_name} ${app}_backup/${db_name}.pgdump" rm "${app}_backup/${db_name}.pgdump" cd "${app}_backup" -for path in $/find . -type f); do +for path in $(find . -type f); do + if [ "${app}" = "pleroma_source" ]; then + if [ "${path}" = '/opt/pleroma/config/prod.secret.exs' ]; then + continue # skip file that contains passwords + fi + fi target_path=$(echo "${path}" | cut -c2-) source_path=$(realpath "${path}") dir=$(dirname "${target_path}") @@ -32,11 +37,11 @@ for path in $/find . -type f); do done # TODO: Horrible hack, improve. -if [ "${app}" = "pleroma" ]; then +if [ "${app}" = "pleroma_otp" ]; then db_pw=$(cat /etc/pleroma/config.exs | grep password | sed 's/[ ]*password\: *//g' | sed 's/,//g' | sed 's/"//g') elif [ "${app}" = "peertube" ]; then db_pw=$(cat /var/www/peertube/config/production.yaml | grep password | head -1 | sed "s/[ ]*password\: *//g" | sed "s/'//g") fi su postgres -lc "psql -c \"ALTER USER ${app} WITH PASSWORD '${db_pw}';\"" -service "${app}" stop +service "${app}" start