aboutsummaryrefslogtreecommitdiff
path: root/scripts/restore
diff options
context:
space:
mode:
authornemsia <nemsia@nemsia.org>2017-04-30 23:49:00 +0200
committerGitHub <noreply@github.com>2017-04-30 23:49:00 +0200
commit2f578fd2c20ce5e92c45946c4b944f3d125f1748 (patch)
treee1b3f32d846f4608d58652f4a8e6eb8614f2e575 /scripts/restore
parent3a2f559174308a6488bc875f42b28f1d18d3a008 (diff)
downloadmastodon_ynh-2f578fd2c20ce5e92c45946c4b944f3d125f1748.tar.gz
mastodon_ynh-2f578fd2c20ce5e92c45946c4b944f3d125f1748.tar.bz2
mastodon_ynh-2f578fd2c20ce5e92c45946c4b944f3d125f1748.zip
[fix] Restore db with mastodon user
Diffstat (limited to 'scripts/restore')
-rw-r--r--scripts/restore14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/restore b/scripts/restore
index 965f6f0..63ce6ee 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -70,9 +70,8 @@ sudo cp -a ./sources/. "$final_path"
# Set permissions
sudo chown -R $app: "$final_path"
-sudo chmod -R a+rx /home/yunohost.backup/tmp
-
+# Debug
sudo ls -alh "$final_path"
# Change directory for create user & database postgresql
@@ -104,7 +103,16 @@ RAILS_ENV=production bin/bundle exec rails assets:precompile
RCOMMANDS
# restore database
-sudo psql mastodon_production < $YNH_APP_BACKUP_DIR/mastodon_db.sql
+sudo cp $YNH_APP_BACKUP_DIR/mastodon_db.sql $final_path
+
+sudo su - $app <<RECOMMANDS
+dropdb mastodon_production
+createdb mastodon_production
+psql mastodon_production < $YNH_APP_BACKUP_DIR/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