mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-11 19:56:44 +00:00
fix backups and restore.
This commit is contained in:
parent
c3d0fe4623
commit
955df684b6
5 changed files with 39 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -77,3 +77,5 @@ Nginx/default.conf
|
|||
|
||||
Certs/StatusPageCerts/*.crt
|
||||
Certs/StatusPageCerts/*.key
|
||||
|
||||
Backups/*.backup
|
||||
|
|
|
|||
1
Backups/README.md
Normal file
1
Backups/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
This is where all the database backups will be stored.
|
||||
11
backup.sh
11
backup.sh
|
|
@ -1 +1,10 @@
|
|||
docker run -it --rm --entrypoint sh debug/ubuntu
|
||||
# This file takes last 30 days backup. Make sure you run this file atleast once/day.
|
||||
# The backup will be in the format of db-(date of the month).backup
|
||||
# Before the backup, please make sure DATABASE_BACKUP_* ENV vars in config.env is set properly.
|
||||
|
||||
export $(grep -v '^#' config.env | xargs)
|
||||
|
||||
sudo docker run -it --net=host --rm \
|
||||
--env-file config.env \
|
||||
--volume=$(pwd)$DATABASE_BACKUP_DIRECTORY:/var/lib/postgresql/data \
|
||||
postgres:latest /usr/bin/pg_dump -Fc --dbname=postgresql://$DATABASE_BACKUP_USERNAME:$DATABASE_BACKUP_PASSWORD@$DATABASE_BACKUP_HOST:$DATABASE_BACKUP_PORT/$DATABASE_BACKUP_NAME --file=/var/lib/postgresql/data/db-$(date +%d).backup
|
||||
|
|
@ -101,4 +101,19 @@ SUBSCRIPTION_PLAN_BASIC=Basic,<planMonthlyId>,<planYearlyId>,0,0,1,0
|
|||
SUBSCRIPTION_PLAN_GROWTH=Growth,<planMonthlyId>,<planYearlyId>,0,0,2,14
|
||||
SUBSCRIPTION_PLAN_ENTERPRISE=Enterprise,<planMonthlyId>,<planYearlyId>,-1,-1,3,14
|
||||
|
||||
STATUS_PAGE_CNAME_RECORD=statuspage.oneuptime.com
|
||||
STATUS_PAGE_CNAME_RECORD=statuspage.oneuptime.com
|
||||
|
||||
|
||||
DATABASE_BACKUP_DIRECTORY=/Backups
|
||||
DATABASE_BACKUP_HOST=localhost
|
||||
DATABASE_BACKUP_PORT=5400
|
||||
DATABASE_BACKUP_USERNAME=postgres
|
||||
DATABASE_BACKUP_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
||||
|
||||
|
||||
DATABASE_RESTORE_DIRECTORY=/Backups
|
||||
DATABASE_RESTORE_HOST=localhost
|
||||
DATABASE_RESTORE_PORT=5400
|
||||
DATABASE_RESTORE_USERNAME=postgres
|
||||
DATABASE_RESTORE_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
||||
DATABASE_RESTORE_FILENAME=db-12.backup
|
||||
10
restore.sh
10
restore.sh
|
|
@ -0,0 +1,10 @@
|
|||
# This file takes last 30 days backup. Make sure you run this file atleast once/day.
|
||||
# The backup will be in the format of db-(date of the month).backup
|
||||
# Before the backup, please make sure DATABASE_RESTORE_* ENV vars in config.env is set properly.
|
||||
|
||||
export $(grep -v '^#' config.env | xargs)
|
||||
|
||||
sudo docker run -it --net=host --rm \
|
||||
--env-file config.env \
|
||||
--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…
Add table
Reference in a new issue