我已经安排了我的CKAN数据库的备份,该数据库使用cron驻留在远程UNIX机器上。我使用下面的代码运行一个简单的脚本:
. /usr/lib/ckan/default/bin/activate
cd /usr/lib/ckan/default/src/ckan
paster db dump --config=/etc/ckan/default/production.ini /home/gisadmin/CKAN_backup_tmp.pg
当我手动运行脚本时,脚本总是成功的。但是,cron作业有时会成功运行,有时会失败,并显示以下错误消息。为了测试这个,我安排了每小时运行一次的工作,大约一半的时间都没有成功,我没看到真正的模式。
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
result = self.command()
File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 141, in command
self._load_config()
File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 96, in _load_config
load_environment(conf.global_conf, conf.local_conf)
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 232, in load_environment
p.load_all(config)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 134, in load_all
load(*plugins)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 167, in load
plugins_update()
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 116, in plugins_update
environment.update_config()
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 357, in update_config
plugin.configure(config)
File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/plugin.py", line 77, in configure
self._check_urls_and_permissions()
File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/plugin.py", line 121, in _check_urls_and_permissions
if not self._read_connection_has_correct_privileges():
File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/plugin.py", line 164, in _read_connection_has_correct_privileges
write_connection.execute(u'CREATE TABLE _foo ()')
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1449, in execute
params)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1628, in _execute_text
statement, parameters
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
context)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
context)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 331, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (IntegrityError) duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL: Key (typname, typnamespace)=(_foo, 2200) already exists.
'CREATE TABLE _foo ()' {}
非常感谢任何帮助。
感谢。
答案 0 :(得分:0)
我认为这是数据存储区代码中的一个错误。如果在运行备份之前禁用数据存储插件,则不会发生这种情况。例如,您可以创建production.ini
文件的副本,该文件完全相同但删除了数据存储区插件,并将其用于paster db dump
命令。
或者你可以直接使用PostgreSQL&#39; pg_dump
命令。
请注意,在备份CKAN站点时,需要备份一些内容:
paster db dump
命令或pg_dump
将获得此信息。paster db dump
能够得到这个,但{@ 1}}应该可以。{/ li>
pg_dump
将是一种简单的方法来支持这一点。