Closes #21951: Add convenience scripts for database management (#22113)

This commit is contained in:
Jeremy Stretch
2026-05-05 09:28:05 -04:00
committed by GitHub
parent 00791344e6
commit d81c2cb739
3 changed files with 25 additions and 0 deletions

7
scripts/drop_database.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
DB=${1:-netbox}
# Drop and re-create the database locally
sudo -u postgres psql -c "drop database $DB"
sudo -u postgres psql -c "create database $DB"

11
scripts/load_database.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
DB=${2:-netbox}
# Drop and re-create the database locally
sudo -u postgres psql -c "DROP DATABASE $DB"
sudo -u postgres psql -c "CREATE DATABASE $DB"
sudo -u postgres psql -c "GRANT CREATE ON DATABASE $DB TO $DB"
# Load tables from the production dump
sudo -u postgres psql $DB < $1

7
scripts/save_database.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
DB=${2:-netbox}
# Dump the database to a file
sudo -u postgres pg_dump $DB > $1