Restoring Discourse from another server


(Slack-Moehrle) #1

We have a Discourse installation of version 1.2 and we are upgrading to to a new box with Discourse 1.6.

I followed these instructions for setting up the new server: discourse/INSTALL-cloud.md at master · discourse/discourse · GitHub

I backed-up all the data and copied it to the new server in /var/discourse/shared/standalone/backups/default. This is about 3.5gb

I did a restore using the web interface and after 16 hours it still says Migrating Database. I tried to refresh and I then get a Page Not Found and no user id’s exist anymore. I can still create a new one.

I tried to restore via the command-line using: Is there any way to restore your site from backup in the terminal?

But script/discourse doesn’t seem to exist. I have a scripts in my root but it only contains docker-gc and mk_swapfile

Any ideas?


(Régis Hanol) #2

script/discourse is inside the container at /var/www/discourse/script/discourse.

Alternatively, when you enter the container, you can just use discourse restore ....


(Slack-Moehrle) #3

But I don’t have a /var/www/discourse on the file system.

Edit: The instructions I followed above have everything going into /var/discourse

Edit 2: I decided to try running a backup to see how large it was. If it was about 3.5gb then my last restore worked on some level. It wasn’t it took just a few seconds. But what I did notice is that the backup said:

2016-08-09 11:12:41] Making sure '/var/www/discourse/tmp/backups/default/2016-08-09-111239' exists...
[2016-08-09 11:12:41] Making sure '/var/www/discourse/public/backups/default' exists...
[2016-08-09 11:12:41] Enabling readonly mode...
[2016-08-09 11:12:41] Pausing sidekiq...

It too says /var/www/discourse but I just don’t have this:

$ la -al /var/
total 60
drwxr-xr-x 15 root root     4096 Jul 29 14:05 .
drwxr-xr-x 24 root root     4096 Jul 29 13:46 ..
drwxr-xr-x  2 root root     4096 Aug  7 07:35 backups
drwxr-xr-x 15 root root     4096 Jul 29 13:48 cache
drwxrwsrwt  2 root whoopsie 4096 Jul 19 16:49 crash
drwxr-xr-x 11 root root     4096 Aug  4 12:41 discourse
drwxr-xr-x 67 root root     4096 Jul 29 14:03 lib
drwxrwsr-x  2 root staff    4096 Apr 12 16:14 local
lrwxrwxrwx  1 root root        9 Jul 29 13:37 lock -> /run/lock
drwxrwxr-x 12 root syslog   4096 Aug  9 07:05 log
drwxrwsr-x  2 root mail     4096 Jul 19 16:42 mail
drwxrwsrwt  2 root whoopsie 4096 Jul 19 16:49 metrics
drwxr-xr-x  2 root root     4096 Jul 19 16:42 opt
lrwxrwxrwx  1 root root        4 Jul 29 13:37 run -> /run
drwxr-xr-x  2 root root     4096 Jun 29 16:13 snap
drwxr-xr-x  7 root root     4096 Jul 19 16:47 spool
drwxrwxrwt  5 root root     4096 Aug  9 07:01 tmp

(Jay Pfaffman) #4

Those files are inside the container (so it’s a whole different file system). To get inside the container

sudo su
cd /var/discourse 
./launcher enter app 

And then do the other stuff…


(Slack-Moehrle) #5

@pfaffman that was the step I was missing. Thank you.

I tried to import and realized I needed to install thor. After installing, I get:

URGENT: FATAL:  Peer authentication failed for user "discourse"
 Failed to initialize site default
Starting restore: public/backups/default/cocos2d-x-forum-2016-08-03-164447.tar.gz
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': FATAL:  Peer authentication failed for user "discourse" (PG::ConnectionBad)
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
    from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
    from /usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/connection_handling.rb:87:in `connection'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/attributes.rb:93:in `columns'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/attributes.rb:98:in `columns_hash'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/core.rb:173:in `block in find_by'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/core.rb:173:in `each'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/core.rb:173:in `all?'
    from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7/lib/active_record/core.rb:173:in `find_by'
    from /var/www/discourse/lib/discourse.rb:282:in `system_user'
    from script/discourse:77:in `restore'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from script/discourse:227:in `<main>'

I’m researching a solution, starting with this: FATAL: Peer authentication failed for user “discourse”


(Jay Pfaffman) #6

You’re welcome. It’s an step one to miss when you’re starting out with Docker, and it’s so obvious to folks who’ve been doing it for even just a little while that it’s hard for them (I’m not quite one of them!) to remember.

I’m not familiar with the authentication problem, though when I solved a similar one last week, I entered the container that held the database and entered there the SQL to add a user & password and give that user access to the database.


(Slack-Moehrle) #7

solved. The box I was using just couldn’t keep up. Changing to a faster box worked the first time flawless.