Replicating NetBox may be useful for several reasons - my reason is to migrate to a new server.
Once a new instance of NetBox is installed, the database on the old server will need to be dumped to file.
pg_dump --username netbox --password --host localhost netbox > netbox.sql
Move the netbox.sql
file to the new server.
The PostgreSQL user accounts and permissions are not included in the dump. The PostgreSQL users you setup for the new installation are what will be active.
Drop the “old” database (the one created during the installation) to avoid any potential conflicts.
sudo -u postgres psql -c 'drop database netbox'
Create a new DB.
sudo -u postgres psql -c 'create database netbox'
Import the old DB into the new one.
sudo -u postgres psql netbox < netbox.sql
I'm not sure that this is the correct way to make the DB import a success, but the only way I've gotten past any errors after importing is to run the NetBox update script.
/opt/netbox/upgrade.sh