Error when restore DB backup

Hello. I’ve just installed fresh Discourse, created backup, then trying to restore:

    [2018-07-25 23:04:18] [STARTED]
    [2018-07-25 23:04:18] 'systemsupport' has started the restore!
    [2018-07-25 23:04:18] Marking restore as running...
    [2018-07-25 23:04:18] Making sure /var/www/discourse/tmp/restores/default/2018-07-25-230418 exists...
    [2018-07-25 23:04:18] Copying archive to tmp directory...
    [2018-07-25 23:04:18] Unzipping archive, this may take a while...
    [2018-07-25 23:04:18] No metadata file to extract.
    [2018-07-25 23:04:18] Validating metadata...
    [2018-07-25 23:04:18]   Current version: 20180724070554
    [2018-07-25 23:04:18]   Restored version: 20180724070554
    [2018-07-25 23:04:18] Extracting dump file...
    [2018-07-25 23:04:18] Cannot restore into different schema, restoring in-place
    [2018-07-25 23:04:18] Enabling readonly mode...
    [2018-07-25 23:04:18] Pausing sidekiq...
    [2018-07-25 23:04:18] Waiting for sidekiq to finish running jobs...
    [2018-07-25 23:04:18] Restoring dump file... (can be quite long)
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] set_config
    [2018-07-25 23:04:18] ------------
    [2018-07-25 23:04:18] (1 row)
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] SET
    [2018-07-25 23:04:18] ERROR:  function "raise_email_logs_reply_key_readonly" already exists with same argument types
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
...
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \.
    [2018-07-25 23:04:18] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:18] LINE 1: 1 b5f8c7fa18aa60222bd2ac38f8c5cba6cc5386673716313889b2800b03...
    [2018-07-25 23:04:18] ^
    [2018-07-25 23:04:18] invalid command \.
    [2018-07-25 23:04:18] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:18] invalid command \.
    [2018-07-25 23:04:18] ERROR:  syntax error at or near "environment"
    [2018-07-25 23:04:18] LINE 1: environment production 2018-07-25 22:55:59.543594 2018-07-25...
    [2018-07-25 23:04:18] ^
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \N
    [2018-07-25 23:04:18] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 Getting Started
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 Gold 2018-07-25 22:56:00.266952 2018-07-25 22:56:00.266952
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "17"
    [2018-07-25 23:04:19] LINE 1: 17 Reader
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "3"
    [2018-07-25 23:04:19] LINE 1: 3 Site Feedback 808281 2 0 2018-07-25 22:55:55.997421 2018-0...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 8 2018-07-25 22:56:06.102966 2018-07-25 22:56:06.102966 0 ...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 2 13 2018-07-25 22:56:00.797882 2018-07-25 22:56:00.797882...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 primary dddddd 1 2018-07-25 22:56:03.857677 2018-07-25 22:...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 Dark 1 2018-07-25 22:56:03.856583 2018-07-25 22:56:03.8565...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 1 1 0 0 0 0 0
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 -1 no_email 621105e14c0f91ed41ca17eadbbaad54 f f 2018-07-2...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 10 -1 2018-07-25 22:56:00.688886 2018-07-25 22:56:00.68888...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "0"
    [2018-07-25 23:04:19] LINE 1: 0 everyone 2018-07-25 22:56:00.050399 2018-07-25 22:56:00.05...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 12 -1 {"badge_id":41,"badge_name":"First Emoji","badge_slu...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 83373730757312d49d0ab461e820ffadd16a7508 .png 20 20 1 /upl...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "1"
    [2018-07-25 23:04:19] LINE 1: 1 discourse-narrative-bot 1 JSON {"topic_id":11,"track":"Dis...
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \N
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  syntax error at or near "bookmark"
    [2018-07-25 23:04:19] LINE 1: bookmark f
    [2018-07-25 23:04:19] ^
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] ERROR:  current transaction is aborted, commands ignored until end of transaction block
    [2018-07-25 23:04:19] EXCEPTION: psql failed
    [2018-07-25 23:04:19] /var/www/discourse/lib/backup_restore/restorer.rb:327:in `restore_dump'
    /var/www/discourse/lib/backup_restore/restorer.rb:68:in `run'
    /var/www/discourse/lib/backup_restore/backup_restore.rb:167:in `block in start!'
    /var/www/discourse/lib/backup_restore/backup_restore.rb:164:in `fork'
    /var/www/discourse/lib/backup_restore/backup_restore.rb:164:in `start!'
    /var/www/discourse/lib/backup_restore/backup_restore.rb:23:in `restore!'
    /var/www/discourse/app/controllers/admin/backups_controller.rb:103:in `restore'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/abstract_controller/base.rb:194:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/rendering.rb:30:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:132:in `run_callbacks'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/abstract_controller/callbacks.rb:41:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/rescue.rb:22:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/notifications.rb:168:in `block in instrument'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/notifications.rb:168:in `instrument'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/abstract_controller/base.rb:134:in `process'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionview-5.2.0/lib/action_view/rendering.rb:32:in `process'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/mini_profiler/profiling_methods.rb:78:in `block in profile_method'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal.rb:191:in `dispatch'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_controller/metal.rb:252:in `dispatch'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:34:in `serve'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/routing/mapper.rb:48:in `serve'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/journey/router.rb:52:in `block in serve'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/journey/router.rb:35:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/journey/router.rb:35:in `serve'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/routing/route_set.rb:840:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-protection-2.0.3/lib/rack/protection/frame_options.rb:31:in `call'
    /var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:24:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/tempfile_reaper.rb:15:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/conditional_get.rb:38:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
    /var/www/discourse/lib/middleware/anonymous_cache.rb:214:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/cookies.rb:670:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:98:in `run_callbacks'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/logster-1.2.9/lib/logster/middleware/reporter.rb:31:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/rack/logger.rb:38:in `call_app'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/rack/logger.rb:28:in `call'
    /var/www/discourse/config/initializers/100-quiet_logger.rb:16:in `call'
    /var/www/discourse/config/initializers/100-silence_logger.rb:29:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/request_id.rb:27:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/executor.rb:14:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/mini_profiler/profiler.rb:174:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/message_bus-2.1.5/lib/message_bus/rack/middleware.rb:63:in `call'
    /var/www/discourse/lib/middleware/request_tracker.rb:180:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:524:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie.rb:190:in `public_send'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie.rb:190:in `method_missing'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/urlmap.rb:68:in `block in call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `call'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:606:in `process_client'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:701:in `worker_loop'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:549:in `spawn_missing_workers'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:142:in `start'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/unicorn-5.4.0/bin/unicorn:126:in `<top (required)>'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/bin/unicorn:23:in `load'
    /var/www/discourse/vendor/bundle/ruby/2.5.0/bin/unicorn:23:in `<main>'
    [2018-07-25 23:04:19] Trying to rollback...
    [2018-07-25 23:04:19] invalid command \.
    [2018-07-25 23:04:19] Rolling back...
    [2018-07-25 23:04:19] Notifying 'systemsupport' of the end of the restore...

This suggests you are not running a standard install. Can you describe your exact setup?

Hmm, default install…
Also I set disable_emails=t and rebuilt
What can be different for such behavior?

Where was the backup created? If it was another system, you should upgrade it and then try the restore.

I still see this when the database versions don’t match, I think.

1 Like

It’s on the same version, just after ./launcher rebuild app => create backup => restore.

And by “default install” you mean https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md?

DId you initiate the backup/restore from the command line or the web interface?

Yes, default instructions.

From web interface

You can try rebuilding again.

Why are you doing a backup and restore?

I tried (with rm -rf shared), but with no success.
I’m migrating from another forum system, so I do it step=>backup=>step=>backup (and if something fails => restore)

My guess is that the old system is not on the same version of postgres as the new system.

What does

./launcher enter app
psql --version

return on each system?

I’d rebuild the old system from the command line and then rebuild the new system from the command line.

Oh, and you might see what

./discourse-doctor 

says about both systems. (I tihnk that discourse-doctor does not check for postgres version and that it should).

psql (PostgreSQL) 10.4 (Ubuntu 10.4-2.pgdg16.04+1)

And it is the exact same on BOTH systems?

What do you mean - on each system? I have only 1 system

Where are you doing this migration?

And this is inside a docker container?

On my machine, similar to this https://github.com/Haulmont/useresponse-to-discourse

I think, it’s not important, because I backuped fresh version of discourse and tried to restore. So I have fresh discourse and admin account (rake admin:create) and then backup=>restore ==> failure

Discourse version v2.1.0.beta2 +478

I’ve tried to install discourse on another computer (fresh discourse without modifications) and I have the same error. #bug @sam
varsion:stable is ok

So you did a new install. And then immediately made a backup and tried to restore it?

Actually I have the same issue. I have created a backup and then reinstalled Discourse with the same Ansible script, and now I cannot import the backup.

It looks like I’ve been able to upload an older backup, but not the last one.

There may be a problem with the last Discourse version not creating a good backup file.

[2018-07-26 19:26:32] Cannot restore into different schema, restoring in-place
[2018-07-26 19:26:32] Enabling readonly mode…
[2018-07-26 19:26:32] Pausing sidekiq…
[2018-07-26 19:26:32] Waiting for sidekiq to finish running jobs…
[2018-07-26 19:26:32] Restoring dump file… (can be quite long)
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] set_config
[2018-07-26 19:26:32] ------------
[2018-07-26 19:26:32] (1 row)
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] SET
[2018-07-26 19:26:32] ERROR: function “raise_email_logs_reply_key_readonly” already exists with same argument types
[2018-07-26 19:26:32] ERROR: current transaction is aborted, commands ignored until end of transaction block
[2018-07-26 19:26:32] ERROR: current transaction is aborted, commands ignored until end of transaction block
[2018-07-26 19:26:32] ERROR: current transaction is aborted, commands ignored until end of transaction block

Discourse Restore Backup error log.txt (344.9 KB)

here is the backup archive Dropbox - production-2018-07-26-174434-v20180724070554.tar.gz - Simplify your life

Seems related to this commit:

https://github.com/discourse/discourse/commit/fad9c2b97113ddbac16d968c38edb7ab47aa8eb9#diff-418730deb7e952df666b9277c1278ec7R14

4 Likes