5 if [ "$#" -lt 2 ]; then
6 echo 'Need two arguments: service name and DB name.'
9 if [ ! "$1" = "pleroma" ] && [ ! "$1" = "peertube" ]; then
10 echo "Need legal service name (pleroma or peertube)."
18 mv "/home/plom/${app}_backup.tar" /tmp/
20 tar xf "${app}_backup.tar"
22 su postgres -c "pg_restore -c -1 -d ${db_name} ${app}_backup/${db_name}.pgdump"
23 rm "${app}_backup/${db_name}.pgdump"
26 for path in $/find . -type f); do
27 target_path=$(echo "${path}" | cut -c2-)
28 source_path=$(realpath "${path}")
29 dir=$(dirname "${target_path}")
31 cp -a "${source_path}" "${target_path}"
34 # TODO: Horrible hack, improve.
35 if [ "${app}" = "pleroma" ]; then
36 db_pw=$(cat /etc/pleroma/config.exs | grep password | sed 's/[ ]*password\: *//g' | sed 's/,//g' | sed 's/"//g')
37 elif [ "${app}" = "peertube" ]; then
38 db_pw=$(cat /var/www/peertube/config/production.yaml | grep password | head -1 | sed "s/[ ]*password\: *//g" | sed "s/'//g")
40 su postgres -lc "psql -c \"ALTER USER ${app} WITH PASSWORD '${db_pw}';\""