$ docker logs ctfd_ctfd_1
Waiting for db to be ready
.db is ready
Starting CTFd
* Loaded module, <module 'CTFd.plugins.keys' from '/opt/CTFd/CTFd/plugins/keys/__init__.py'>
* Loaded module, <module 'CTFd.plugins.keys' from '/opt/CTFd/CTFd/plugins/keys/__init__.py'>
* Loaded module, <module 'CTFd.plugins.keys' from '/opt/CTFd/CTFd/plugins/keys/__init__.py'>
* Loaded module, <module 'CTFd.plugins.keys' from '/opt/CTFd/CTFd/plugins/keys/__init__.py'>
/opt/CTFd # python import.py /new-backup.zip
* Loaded module, <module 'CTFd.plugins.keys' from '/opt/CTFd/CTFd/plugins/keys/__init__.py'>
* Loaded module, <module 'CTFd.plugins.challenges' from '/opt/CTFd/CTFd/plugins/challenges/__init__.py'>
Traceback (most recent call last):
File "import.py", line 16, in <module>
import_ctf(sys.argv[1], segments=segments)
File "/opt/CTFd/CTFd/utils/__init__.py", line 976, in import_ctf
table.insert(entry)
File "/usr/local/lib/python2.7/site-packages/dataset/table.py", line 80, in insert
res = self.db.executable.execute(self.table.insert(row))
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 165, in execute
result = self._query(query)
File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 321, in _query
conn.query(q)
File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1061, in _read_query_result
result.read()
File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1349, in read
first_packet = self.connection._read_packet()
File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1018, in _read_packet
packet.check_error()
File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 384, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
sqlalchemy.exc.IntegrityError: (pymysql.err.IntegrityError) (1452, u'Cannot add or update a child row: a foreign key constraint fails (`ctfd`.`tracking`, CONSTRAINT `tracking_ibfk_1` FOREIGN KEY (`team`) REFERENCES `teams` (`id`))') [SQL: u'INSERT INTO tracking (ip, team, date) VALUES (%(ip)s, %(team)s, %(date)s)'] [parameters: {'date': u'2018-05-25T11:24:29', 'ip': u'172.19.0.1', 'team': 2}] (Background on this error at: http://sqlalche.me/e/gkpj)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80c2c9cec883 ctfd_ctfd "/opt/CTFd/docker-en…" 16 minutes ago Up 16 minutes 0.0.0.0:9000->8000/tcp ctfd_ctfd_1
d055c8808de5 mariadb:10.2 "docker-entrypoint.s…" 16 minutes ago Up 16 minutes ctfd_db_1
1be242e8fb72 redis:4 "docker-entrypoint.s…" 16 minutes ago Up 16 minutes ctfd_cache_1
I exported a backup of CTFd using the Admin Panel / Config / Backup / Export, and then tried to import it. I get a popup with an "Integrity Error".
In reality, the backup gets partially applied. For example, all keys and hints are lost.
The docker logs do not show more:
To troubleshoot, I tried to use the
import.pyscript in the container.I get the following errors:
So, it says: Cannot add or update a child row: a foreign key constraint fails
Environment
To deploy the containers, I used
docker-compose up --build -d. The 3 containers are up and running.