aboutsummaryrefslogtreecommitdiff
path: root/scripts/restore
diff options
context:
space:
mode:
authorJean-Baptiste Holcroft <jean-baptiste@holcroft.fr>2018-05-01 11:29:25 +0200
committerJean-Baptiste Holcroft <jean-baptiste@holcroft.fr>2018-05-01 11:29:25 +0200
commitf0b132281241bcfdc38be62dd79324b78a4972f2 (patch)
treeef9688ca0989097d0b47f78bd093a588475da22a /scripts/restore
parent1925b3026b2affacd95464ee98525b156313cfb4 (diff)
downloadmastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.tar.gz
mastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.tar.bz2
mastodon_ynh-f0b132281241bcfdc38be62dd79324b78a4972f2.zip
Use latest PostgreSQL helpers
Diffstat (limited to 'scripts/restore')
-rw-r--r--scripts/restore17
1 files changed, 8 insertions, 9 deletions
diff --git a/scripts/restore b/scripts/restore
index 8ca0b5a..8bad156 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -107,15 +107,14 @@ sudo chown -R $app: "$final_path"
# Debug
sudo ls -alh "$final_path"
-# Set UTF8 encoding by default
-sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='false' where datname='template1';"
-sudo su -c "psql" postgres <<< \
- "drop database template1;"
-sudo su -c "psql" postgres <<< \
- "create database template1 encoding='UTF8' template template0;"
-sudo su -c "psql" postgres <<< \
- "update pg_database set datistemplate='true' where datname='template1';"
+# Restore PostgreSQL database
+db_user=$(ynh_sanitize_dbid "$app")
+db_name=$(ynh_sanitize_dbid "$app")
+db_pwd=$(ynh_app_setting_get "$app" db_pwd)
+
+ynh_psql_test_if_first_run
+ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd"
+ynh_psql_execute_file_as_root ./db.sql "$db_name"
# Install rbenv
sudo su - $app <<COMMANDS