mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 07:10:53 +00:00
Update Postgres backup and restore scripts
This commit is contained in:
parent
9cf2ae4326
commit
e7bbe30a88
@ -32,19 +32,16 @@ This will make the database accessible from the localhost:5432.
|
||||
|
||||
### Postgres Backup
|
||||
|
||||
Please make sure you have `pg_dump` and `pg_restore` installed on your local machine.
|
||||
|
||||
To take a backup of the database, use the following command:
|
||||
Please fill the values in config.env file and run the following command to take the backup of the database.
|
||||
|
||||
```
|
||||
# Source Database. This will prompt for the password
|
||||
pg_dump --host=<source_port> --port=<target_port> --username=<source_username> --password --dbname=oneuptimedb --file=oneuptime.sql
|
||||
./backup.sh
|
||||
```
|
||||
|
||||
### Postgres Restore
|
||||
|
||||
To restore the database, use the following command:
|
||||
Please fill the values in config.env file and run the following command to restore the database.
|
||||
|
||||
```
|
||||
# Target Database. This will prompt for the password
|
||||
pg_restore --host=localhost --port=5432 --username=<target_username> --dbname=oneuptimedb --password --file=oneuptime.sql
|
||||
./restore.sh
|
||||
```
|
||||
|
@ -119,6 +119,7 @@ SUBSCRIPTION_PLAN_SCALE=Scale,priceMonthlyId,priceYearlyId,0,0,3,0
|
||||
SUBSCRIPTION_PLAN_ENTERPRISE=Enterprise,priceMonthlyId,priceYearlyId,-1,-1,4,14
|
||||
|
||||
|
||||
# If you want to run the backup script, then you need to fill these values.
|
||||
DATABASE_BACKUP_DIRECTORY=/Backups
|
||||
DATABASE_BACKUP_HOST=localhost
|
||||
DATABASE_BACKUP_PORT=5400
|
||||
@ -127,8 +128,9 @@ DATABASE_BACKUP_USERNAME=postgres
|
||||
DATABASE_BACKUP_PASSWORD=${DATABASE_PASSWORD}
|
||||
|
||||
|
||||
# If you want to run the restore script, then you need to fill these values. Use host.docker.internal if you want to use the host machine's IP.
|
||||
DATABASE_RESTORE_HOST=host.docker.internal
|
||||
DATABASE_RESTORE_DIRECTORY=/Backups
|
||||
DATABASE_RESTORE_HOST=localhost
|
||||
DATABASE_RESTORE_PORT=5400
|
||||
DATABASE_RESTORE_NAME=oneuptimedb
|
||||
DATABASE_RESTORE_USERNAME=postgres
|
||||
|
@ -17,6 +17,7 @@ git pull
|
||||
|
||||
sudo docker run --net=host --rm \
|
||||
--env-file config.env \
|
||||
--add-host=host.docker.internal:host-gateway \
|
||||
--volume=$(pwd)$DATABASE_RESTORE_DIRECTORY:/var/lib/postgresql/data \
|
||||
postgres:latest /usr/bin/pg_restore --dbname=postgresql://$DATABASE_RESTORE_USERNAME:$DATABASE_RESTORE_PASSWORD@$DATABASE_RESTORE_HOST:$DATABASE_RESTORE_PORT/$DATABASE_RESTORE_NAME /var/lib/postgresql/data/$DATABASE_RESTORE_FILENAME
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user