Skip to content

Commit 2139811

Browse files
authored
Merge pull request #74 from chriswoodfield/chriswoodfield/db-export-fix
Corrected container names for "invoke db-import/export" cp steps
2 parents 2954a44 + 4586575 commit 2139811

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tasks.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ def db_export(context):
252252
print("Exporting the database as an SQL dump...")
253253
if "docker-compose.mysql.yml" in context.nautobot_docker_compose.compose_files:
254254
export_cmd = 'exec db sh -c "mysqldump -u \${NAUTOBOT_DB_USER} –p \${NAUTOBOT_DB_PASSWORD} \${NAUTOBOT_DB_NAME} nautobot > /tmp/nautobot.sql"' # noqa: W605 pylint: disable=anomalous-backslash-in-string
255-
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-mysql-1:/tmp/nautobot.sql nautobot.sql"
255+
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql nautobot.sql"
256256
else:
257257
export_cmd = 'exec db sh -c "pg_dump -h localhost -d \${NAUTOBOT_DB_NAME} -U \${NAUTOBOT_DB_USER} > /tmp/nautobot.sql"' # noqa: W605 pylint: disable=anomalous-backslash-in-string
258-
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-postgres-1:/tmp/nautobot.sql nautobot.sql"
258+
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql nautobot.sql"
259259
docker_compose(context, export_cmd, pty=True)
260260
print("Copying the SQL Dump locally...")
261261
context.run(copy_cmd)
@@ -272,10 +272,10 @@ def db_import(context):
272272

273273
print("Copying DB Dump to DB container...\n")
274274
if "docker-compose.mysql.yml" in context.nautobot_docker_compose.compose_files:
275-
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-mysql-1:/tmp/nautobot.sql"
275+
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql"
276276
import_cmd = 'exec db sh -c "mysql -u \${NAUTOBOT_DB_USER} –p \${NAUTOBOT_DB_PASSWORD} < /tmp/nautobot.sql"' # noqa: W605 pylint: disable=anomalous-backslash-in-string
277277
else:
278-
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-postgres-1:/tmp/nautobot.sql"
278+
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql"
279279
import_cmd = 'exec db sh -c "psql -h localhost -U \${NAUTOBOT_DB_USER} < /tmp/nautobot.sql"' # noqa: W605 pylint: disable=anomalous-backslash-in-string
280280
context.run(copy_cmd)
281281

0 commit comments

Comments
 (0)