Migration Steps missing #922

Closed
opened 2025-12-29 16:27:00 +01:00 by adam · 1 comment
Owner

Originally created by @claughinghouse on GitHub (May 8, 2017).

Issue type:

Missing documentation.

**NetBox version: All
Markup page is below.

Migration from one host to another

Dump the database by first su to postgres user on the current netbox server

# pg_dump netbox > netbox_db.bak

Copy the netbox_db.bak file from /var/lib/psql directory to the new machine.

On the new machine initialize a new database and netbox user with the same database password as before.

# sudo -u postgres psql
psql (9.3.13)
Type "help" for help.

postgres=# CREATE DATABASE netbox;
CREATE DATABASE
postgres=# CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
GRANT
postgres=# \q

You can verify that authentication works issuing the following command and providing the configured password:

# psql -U netbox -h localhost -W

If successful, you will enter a postgres prompt. Type \q to exit.

Copy the netbox_db.bak file on the new to host to /var/lib/pgsql

Become the user and import the database

# pg_dump netbox < netbox_db.bak
Originally created by @claughinghouse on GitHub (May 8, 2017). ### Issue type: Missing documentation. **NetBox version: All Markup page is below. ## Migration from one host to another Dump the database by first `su` to postgres user on the current netbox server ```# sudo su - postgres # pg_dump netbox > netbox_db.bak ``` Copy the netbox_db.bak file from `/var/lib/psql` directory to the new machine. On the new machine initialize a new database and netbox user with the same database password as before. ```no-highlight # sudo -u postgres psql psql (9.3.13) Type "help" for help. postgres=# CREATE DATABASE netbox; CREATE DATABASE postgres=# CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K'; CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox; GRANT postgres=# \q ``` You can verify that authentication works issuing the following command and providing the configured password: ```no-highlight # psql -U netbox -h localhost -W ``` If successful, you will enter a postgres prompt. Type `\q` to exit. Copy the netbox_db.bak file on the new to host to `/var/lib/pgsql` Become the user and import the database ```# sudo su - postgres # pg_dump netbox < netbox_db.bak ```
adam closed this issue 2025-12-29 16:27:00 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 8, 2017):

You're describing the process of replicating a PostgreSQL database, which is well-defined elsewhere and is not specific to NetBox. There's no reason to include it in our documentation.

@jeremystretch commented on GitHub (May 8, 2017): You're describing the process of replicating a PostgreSQL database, which is well-defined elsewhere and is not specific to NetBox. There's no reason to include it in our documentation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#922