Skip to content

Commit

Permalink
Merge pull request #74 from chriswoodfield/chriswoodfield/db-export-fix
Browse files Browse the repository at this point in the history
Corrected container names for "invoke db-import/export" cp steps
  • Loading branch information
jdrew82 authored Sep 19, 2024
2 parents 2954a44 + 4586575 commit 2139811
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ def db_export(context):
print("Exporting the database as an SQL dump...")
if "docker-compose.mysql.yml" in context.nautobot_docker_compose.compose_files:
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
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-mysql-1:/tmp/nautobot.sql nautobot.sql"
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql nautobot.sql"
else:
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
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-postgres-1:/tmp/nautobot.sql nautobot.sql"
copy_cmd = f"docker cp {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql nautobot.sql"
docker_compose(context, export_cmd, pty=True)
print("Copying the SQL Dump locally...")
context.run(copy_cmd)
Expand All @@ -272,10 +272,10 @@ def db_import(context):

print("Copying DB Dump to DB container...\n")
if "docker-compose.mysql.yml" in context.nautobot_docker_compose.compose_files:
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-mysql-1:/tmp/nautobot.sql"
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql"
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
else:
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-postgres-1:/tmp/nautobot.sql"
copy_cmd = f"docker cp nautobot.sql {context.nautobot_docker_compose.project_name}-db-1:/tmp/nautobot.sql"
import_cmd = 'exec db sh -c "psql -h localhost -U \${NAUTOBOT_DB_USER} < /tmp/nautobot.sql"' # noqa: W605 pylint: disable=anomalous-backslash-in-string
context.run(copy_cmd)

Expand Down

0 comments on commit 2139811

Please sign in to comment.