转储CKAN数据库并将其加载到另一个CKAN实例中

时间:2016-07-07 10:14:23

标签: python-2.7 migration ckan

我已经尝试过多次尝试将CKAN数据库加载到另一台主机中的另一个CKAN实例。

我的工作流程如下:

A>从生产主机(host_p)

中提取数据库转储
paster db dump -c /etc/ckan/ckan_p_instance/production.ini instance_p_db_dump.sql

B个将转储的数据库文件复制到我的新主机(host_t)

c取代;激活CKAN虚拟环境

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

d取代;清理host_t

中的现有CKAN数据库
paster db clean -c /etc/ckan/spatial_hub/development.ini

E - 代替;将转储的文件加载到CKAN host_t实例中。

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

F>我收到以下错误:

/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

我不确定如何解释上述错误,因此非常感谢任何帮助。

1 个答案:

答案 0 :(得分:4)

看起来您正在遇到a known bug,其中密码中的特殊字符未被正确转义。由于此原因和其他原因,将不推荐使用paster db dumpload命令。官方的建议是使用PostgreSQL自己的工具(例如pg_dumppg_restore)与paster db upgrade(将被保留)相结合。

作为短期解决方法,请确保您的密码不包含shell特有的字符。

更新:CKAN文档已更新,其中包含有关how to dump and load the CKAN database using pg_dump and pg_restore的信息。