Issues with restoring backup to discourse

This sounds like the problem mentioned in Can't restore a backup if it includes link to Discourse onebox :anxious_face_with_sweat:

You should be able to fix this during the restore, but you need to do it on the shell.

cd /var/discourse
./launcher enter app

# start the restore with the --pause argument
discourse restore --pause <backup_filename>

It will pause the restore process at two points:

  1. Before DB migrations are run – you can ignore that; press a key to continue
  2. Before Uploads are restored. You will have access to the unmodified uploads table (no remaps have been run yet) which allows you to fix uploads before the restore process aborts because of them.

Now, open another SSH session to your server and start a rails console:

cd /var/discourse
./launcher enter app

rails c

You’ll need to figure out which Post is causing the restore to fail. If you are lucky, you’ll find it by executing the following in the rails console:

current_db = RailsMultisite::ConnectionManagement.current_db
cdn_path = SiteSetting.cdn_path("/uploads/#{current_db}/original").sub(/https?:/, "")
Post.where("cooked LIKE '%#{cdn_path}%'")
6 Likes