mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
make db backups options work
This commit is contained in:
parent
fc48c308d1
commit
7d5642860d
2
.gitignore
vendored
2
.gitignore
vendored
@ -83,3 +83,5 @@ Certs/ServerCerts/*.crt
|
|||||||
Certs/ServerCerts/*.key
|
Certs/ServerCerts/*.key
|
||||||
|
|
||||||
Backups/*.backup
|
Backups/*.backup
|
||||||
|
Backups/*.sql
|
||||||
|
Backups/*.tar
|
||||||
|
10
backup.sh
10
backup.sh
@ -8,9 +8,17 @@ echo "Starting backup...."
|
|||||||
|
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
|
# Backup as SQL, CANNOT be used with pg_reestore.
|
||||||
sudo docker run --net=host --rm \
|
sudo docker run --net=host --rm \
|
||||||
--env-file config.env \
|
--env-file config.env \
|
||||||
--volume=$(pwd)$DATABASE_BACKUP_DIRECTORY:/var/lib/postgresql/data \
|
--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
|
postgres:latest /usr/bin/pg_dump --format=plain --clean --create --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).sql
|
||||||
|
|
||||||
|
# Backup as Tar can be used with pg_restore
|
||||||
|
sudo docker run --net=host --rm \
|
||||||
|
--env-file config.env \
|
||||||
|
--volume=$(pwd)$DATABASE_BACKUP_DIRECTORY:/var/lib/postgresql/data \
|
||||||
|
postgres:latest /usr/bin/pg_dump --format=tar --clean --create --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).tar
|
||||||
|
|
||||||
|
|
||||||
echo "Backup completed successfully!"
|
echo "Backup completed successfully!"
|
@ -105,6 +105,7 @@ STATUS_PAGE_CNAME_RECORD=statuspage.oneuptime.com
|
|||||||
DATABASE_BACKUP_DIRECTORY=/Backups
|
DATABASE_BACKUP_DIRECTORY=/Backups
|
||||||
DATABASE_BACKUP_HOST=localhost
|
DATABASE_BACKUP_HOST=localhost
|
||||||
DATABASE_BACKUP_PORT=5400
|
DATABASE_BACKUP_PORT=5400
|
||||||
|
DATABASE_BACKUP_NAME=oneuptimedb
|
||||||
DATABASE_BACKUP_USERNAME=postgres
|
DATABASE_BACKUP_USERNAME=postgres
|
||||||
DATABASE_BACKUP_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
DATABASE_BACKUP_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
||||||
|
|
||||||
@ -112,9 +113,10 @@ DATABASE_BACKUP_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
|||||||
DATABASE_RESTORE_DIRECTORY=/Backups
|
DATABASE_RESTORE_DIRECTORY=/Backups
|
||||||
DATABASE_RESTORE_HOST=localhost
|
DATABASE_RESTORE_HOST=localhost
|
||||||
DATABASE_RESTORE_PORT=5400
|
DATABASE_RESTORE_PORT=5400
|
||||||
|
DATABASE_RESTORE_NAME=oneuptimedb
|
||||||
DATABASE_RESTORE_USERNAME=postgres
|
DATABASE_RESTORE_USERNAME=postgres
|
||||||
DATABASE_RESTORE_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
DATABASE_RESTORE_PASSWORD={{ .Env.DATABASE_PASSWORD }}
|
||||||
DATABASE_RESTORE_FILENAME=db-12.backup
|
DATABASE_RESTORE_FILENAME=db-31.backup
|
||||||
|
|
||||||
ANALYTICS_KEY=
|
ANALYTICS_KEY=
|
||||||
ANALYTICS_HOST=
|
ANALYTICS_HOST=
|
||||||
|
Loading…
Reference in New Issue
Block a user