Dimitris
Dimitris

Reputation: 485

Dump the CKAN database and Load it in another CKAN instance

I have made several unsuccessful attempts to load the CKAN database into another CKAN instance in a different host.

My workflow is the following:

A> Extract the db dump from the production host (host_p)

paster db dump -c /etc/ckan/ckan_p_instance/production.ini instance_p_db_dump.sql

B> Copy the dumped database file to my new host (host_t)

C> Activate the CKAN virtual environment

. /usr/lib/ckan/ckan_t_instance/bin/activate

D> Clean the existing CKAN database in host_t

paster db clean -c /etc/ckan/spatial_hub/development.ini

E> Load the dumped file into the CKAN host_t instance.

paster db load -c /etc/ckan/spatial_hub/development.ini ~/instance_p_db_dump.sql

F> I get the following error:

/bin/sh: 1: Syntax error: "&&" unexpected
Traceback (most recent call last):
  File "/usr/lib/ckan/spatial_hub/bin/paster", line 11, in <module>
    sys.exit(run())
  File "/usr/lib/ckan/spatial_hub/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/spatial_hub/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/spatial_hub/local/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/spatial_hub/src/ckan/ckan/lib/cli.py", line 238, in command
    self.load()
  File "/usr/lib/ckan/spatial_hub/src/ckan/ckan/lib/cli.py", line 315, in load
    pg_cmd = self._postgres_load(dump_path)
  File "/usr/lib/ckan/spatial_hub/src/ckan/ckan/lib/cli.py", line 290, in _postgres_load
    self._run_cmd(pg_cmd)
  File "/usr/lib/ckan/spatial_hub/src/ckan/ckan/lib/cli.py", line 297, in _run_cmd
    raise SystemError('Command exited with errorcode: %i' % retcode)
SystemError: Command exited with errorcode: 2

I am not sure how to interpret the above error so any help would be greatly appreciated.

Upvotes: 1

Views: 1806

Answers (1)

Florian Brucker
Florian Brucker

Reputation: 10365

Looks like your running into a known bug, where special characters in the password are not properly escaped. The paster db dump and load commands are going to be deprecated for this and other reasons. The official suggestion is to use PostgreSQL's own tools (e.g. pg_dump and pg_restore) in combination with paster db upgrade (which will be kept) instead.

As a short-term workaround, make sure that your password does not contain characters that are special for your shell.

Update: The CKAN documentation has been updated with information on how to dump and load the CKAN database using pg_dump and pg_restore.

Upvotes: 5

Related Questions