Skip to main content

Database backup and restore examples

This is a guide on how to backup and restore your database using an Infrahub command line tool. Please see this topic for the requirements for using the tool and an explanation of how it works.

This guide assumes that you cloned the Infrahub repository to your machine, but you can also copy the content of this tool's Python file into a local Python file and run it that way.

Backup a remote Infrahub database

python -m utilities.db_backup neo4j backup --database-url=172.28.64.1 /infrahub_backups

In this example, the "remote" Infrahub database is accessible at 172.28.64.1 and I want to store the generated backup files in the /infrahub_backups directory.

Backup a local Infrahub database with a non-default backup port

python -m utilities.db_backup neo4j backup --database-backup-port=12345 /infrahub_backups

In this example, I am running the backup command on the same machine that is running the Infrahub docker containers. In this case, port 12345 must also have been set using the NEO4J_server_backup_listen__address environment variable in the Infrahub database container.

Restore a backup on a non-default cypher port

python local_backup_copy.py neo4j restore /infrahub_backups --database-cypher-port=9876

In this example, I am restoring .backup files that exist in the /infrahub_backups directory and my Infrahub database container uses a non-standard port for cypher access: 9876 instead of 7687.