# Error when restore DB backup

**URL:** https://meta.discourse.org/t/error-when-restore-db-backup/93145
**Category:** Self-hosting
**Created:** [July 25, 2018, 11:15pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145 "2018-07-25T23:15:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 25, 2018, 11:15pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/1 "2018-07-25T23:15:05Z")

</div>

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

```plaintext
    [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...

```

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [July 25, 2018, 11:17pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/2 "2018-07-25T23:17:25Z")

</div>

> [@StYas](#):
>
> Cannot restore into different schema, restoring in-place

This suggests you are not running a [standard install](https://meta.discourse.org/t/142537?silent=true). Can you describe your exact setup?

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 25, 2018, 11:25pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/4 "2018-07-25T23:25:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 4:12am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/5 "2018-07-26T04:12:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 10:28am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/6 "2018-07-26T10:28:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 10:42am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/7 "2018-07-26T10:42:09Z")

</div>

And by “default install” you mean [discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub](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?

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 10:48am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/8 "2018-07-26T10:48:39Z")

</div>

Yes, default instructions.

From web interface

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 10:54am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/9 "2018-07-26T10:54:29Z")

</div>

You can try rebuilding again.

Why are you doing a backup and restore?

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 10:57am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/10 "2018-07-26T10:57:40Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 11:03am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/11 "2018-07-26T11:03:42Z")

</div>

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

What does

```plaintext
./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).

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 11:07am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/12 "2018-07-26T11:07:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 11:07am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/13 "2018-07-26T11:07:47Z")

</div>

And it is the exact same on BOTH systems?

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 11:08am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/14 "2018-07-26T11:08:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 11:09am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/15 "2018-07-26T11:09:30Z")

</div>

> [@StYas](#):
>
> I’m migrating from another forum system, so I do it step=\>backup=\>step=\>backup (and if something fails =\> restore)

Where are you doing this migration?

And this is inside a docker container?

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 11:11am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/16 "2018-07-26T11:11:31Z")

</div>

On my machine, similar to this [GitHub - Haulmont/useresponse-to-discourse: Python scripts to migrate from UseResponse to Discourse forum · GitHub](https://github.com/Haulmont/useresponse-to-discourse)

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 11:15am UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/17 "2018-07-26T11:15:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![StYas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/styas/32/119706_2.png) [@StYas](https://meta.discourse.org/u/StYas)
#### Post date: [July 26, 2018, 1:01pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/18 "2018-07-26T13:01:26Z")

</div>

Discourse version [v2.1.0.beta2 +478](https://github.com/discourse/discourse/compare/a89dd51caee6292754413f34ae8f5e942a5fb06b...tests-passed)

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2018, 6:36pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/20 "2018-07-26T18:36:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![UnivacTwo](https://avatars.discourse-cdn.com/v4/letter/u/df705f/32.png) [@UnivacTwo](https://meta.discourse.org/u/UnivacTwo)
#### Post date: [July 26, 2018, 7:41pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/21 "2018-07-26T19:41:41Z")

</div>

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](https://global.discourse-cdn.com/meta/original/3X/f/b/fb33e2663c9a60febf80e57ec2340e5e7cb41616.txt) (344.9 KB)

here is the backup archive [Dropbox](https://www.dropbox.com/s/87zzy8ct3t6qm68/production-2018-07-26-174434-v20180724070554.tar.gz?dl=0)

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [July 26, 2018, 10:14pm UTC](https://meta.discourse.org/t/error-when-restore-db-backup/93145/22 "2018-07-26T22:14:27Z")

</div>

Seems related to this commit:

[https://github.com/discourse/discourse/commit/fad9c2b97113ddbac16d968c38edb7ab47aa8eb9#diff-418730deb7e952df666b9277c1278ec7R14](https://github.com/discourse/discourse/commit/fad9c2b97113ddbac16d968c38edb7ab47aa8eb9#diff-418730deb7e952df666b9277c1278ec7R14)

[Next page](https://meta.discourse.org/t/error-when-restore-db-backup/93145.md?page=2)
