@@ -15,28 +15,32 @@ First, drop and recreate the PostgreSQL database. The example here assumes the d
15
15
``` bash
16
16
sudo -u postgres psql -c " DROP database netbox;"
17
17
sudo -u postgres psql -c " CREATE database netbox;"
18
-
19
- # NetBox Docker
20
- docker-compose exec postgres sh -c ' psql -U $POSTGRES_USER postgres -c "DROP DATABASE netbox;"'
21
- docker-compose exec postgres sh -c ' psql -U $POSTGRES_USER postgres -c "CREATE DATABASE netbox;"'
22
18
```
23
19
24
20
Next, apply NetBox's database migrations using the ` migrate ` management command. (Ensure that the Python virtual environment is active before attempting to invoke the command.)
25
21
26
22
``` bash
27
23
source /opt/netbox/venv/bin/activate
28
24
./manage.py migrate
29
-
30
- # Netbox Docker
31
- docker-compose exec netbox bash -c " source /opt/netbox/venv/bin/activate && ./manage.py migrate"
32
25
```
33
26
34
27
Finally, load the demo data fixtures from the JSON file.
35
28
36
29
``` bash
37
30
./manage.py loaddata -v 3 netbox-demo-$VERSION .json
31
+ ```
32
+
33
+ ### Docker Commands
34
+
35
+ ```
36
+ # Drop & recreate the database
37
+ docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "DROP DATABASE netbox;"'
38
+ docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "CREATE DATABASE netbox;"'
39
+
40
+ # Apply migrations
41
+ docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py migrate"
38
42
39
- # NetBox Docker
43
+ # Load the demo data
40
44
docker cp netbox-demo-$VERSION.json "$(docker-compose ps -q netbox)":/opt/netbox/netbox/netbox-demo.json
41
45
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py loaddata netbox-demo.json"
42
46
```
@@ -48,8 +52,11 @@ The following steps are necessary **only** if you intend to save a snapshot of d
48
52
``` bash
49
53
source /opt/netbox/venv/bin/activate
50
54
./manage.py dumpdata --natural-foreign --natural-primary -e extras.Script -e extras.Report -e extras.ObjectChange -e django_rq --indent 2 -o netbox-demo-$VERSION .json
55
+ ```
51
56
52
- # NetBox Docker
57
+ ### Docker Commands
58
+
59
+ ```
53
60
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py dumpdata --natural-foreign --natural-primary -e extras.Script -e extras.Report -e extras.ObjectChange --indent 2" > netbox-demo-$VERSION.json
54
61
```
55
62
0 commit comments