aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornemsia <nemsia@nemsia.org>2017-05-01 21:26:46 +0200
committerGitHub <noreply@github.com>2017-05-01 21:26:46 +0200
commit7d9014285df5dcdecbbf381397a636e6ff771c9b (patch)
tree920c30152e9c3c8ae37f7b5af2657106d1cd3966
parente1bf40f646d5ac7ba0e540f5110c29a79a07119d (diff)
downloadmastodon_ynh-7d9014285df5dcdecbbf381397a636e6ff771c9b.tar.gz
mastodon_ynh-7d9014285df5dcdecbbf381397a636e6ff771c9b.tar.bz2
mastodon_ynh-7d9014285df5dcdecbbf381397a636e6ff771c9b.zip
[fix] Restore pg dump
Restore pg dump with mastodon user.
-rw-r--r--scripts/restore15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/restore b/scripts/restore
index 1340796..a57a33f 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -101,8 +101,19 @@ RAILS_ENV=production bin/bundle exec rails db:migrate
RAILS_ENV=production bin/bundle exec rails assets:precompile
RCOMMANDS
-# restore database
-sudo psql mastodon_production < $YNH_APP_BACKUP_DIR/mastodon_db.sql
+# copy database dump
+sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
+sudo chmod a+r $final_path/mastodon_db.sql
+
+# Restore database dump
+sudo su - $app <<RECOMMANDS
+dropdb mastodon_production
+createdb mastodon_production
+psql mastodon_production < $final_path/mastodon_db.sql
+RECOMMANDS
+
+# Remove dump
+sudo rm $final_path/mastodon_db.sql
# Create symlink for ruby
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true