Category/Topic export fails with error "database "discourse_development" does not exist"


(Marcus Baw) #1

I am attempting to export a Category from an up-to-date Discourse Docker deployment (v1.6.0.beta1 +14) on Digital Ocean, using the command line tool kindly documented by @neil in this thread

I’m following these steps:

  • I ssh into the DO Droplet
  • cd /var/discourse
  • execute ./launcher enter app to enter the Docker container
  • su - discourse to become the Discourse user
  • cd var/www/discourse
  • bundle exec script/discourse export_category 15 (I checked beforehand via Rails console that Category id 15 is the one I need)

Unfortunately, it fails with the error
FATAL: database "discourse_development" does not exist (ActiveRecord::NoDatabaseError)

The full stack trace is here

Can anyone help? Is this user error on my part or a bug?
Should I even have a development database in a production docker deploy like mine?
Is this perhaps because I’m using ./launcher enter app rather than ./launcher ssh app?


(Régis Hanol) #2

Can you try this?

cd /var/discourse
./launcher enter app
discourse export_category 15

(Marcus Baw) #3

Woop! thanks @zogstrip. That works.

I did scour Meta for a solution, and also had a look at the source for the /scripts/discourse but I didn’t see anywhere it said about using the discourse command like that, without bundle exec.

That would appear to have solved my problem, but I would say the discourse command line tool needs a little more documentation, just to get people started. I’m far from a discourse n00b and I can see in the source that the CLI tool has command line --help strings for individual features/switches etc, but it needs to be clearer how to get started - eg that you invoke it without bundle exec.

Once again, thanks @zogstrip

Marcus


(Marcus Baw) #4

I’ve now had chance to test the ‘round trip’ of exporting a Category from one Discourse instance and importing it into a different one. Using @zogstrip’s advice above this worked perfectly.

##on the ‘source’ instance:

cd /var/discourse
launcher enter app
discourse export_category [category_number]

transferring the .json file

I transferred the file from the ‘source’ to ‘destination’ instance using a 2-step process:

  1. SFTP from inside the Docker container to the ‘destination’ server and copy the export file to somewhere on the ‘destination’ server filesystem (but remember that this is outside the Docker container)
  2. Copy this file into the Docker container with sudo cp path-file-host /var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE (get container ID from docker ps from where you get the short CID, then docker inspect -f '{{.Id}}' [short CID] which returns the long CID. Thanks to this thread for the help with that.

I know that Docker 1.8 lets you use docker cp but I’m currently on Docker 1.7 and didn’t want to break anything by upgrading right when I need everything to work!

For my own education, I’d be really interested to hear if there is a more elegant or even single-step way of transferring the .json file across from the Docker Container in ‘source’ to inside the Docker Container in ‘destination’.

#on the ‘destination’ machine:

cd /var/discourse
./launcher enter app
cd [to wherever you put the .json file in your destination's Docker container]
discourse import_category [json file]

Marcus