mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-25 20:40:36 +03:00
Add shell script to create backup
This commit is contained in:
parent
be115776b0
commit
8459b49032
49
scripts/prod/CreateBackup.sh
Normal file
49
scripts/prod/CreateBackup.sh
Normal file
|
@ -0,0 +1,49 @@
|
|||
# ====== Create database backup ==========
|
||||
# WARNING! DO NOT RUN THIS FILE AUTOMATICALLY FROM REPOSITORY LOCATION!
|
||||
# Create a copy in secure location @production host. Update backup scripts from repository manually
|
||||
# ========================================
|
||||
|
||||
backupLocation="/home/admuser/backup"
|
||||
pgUser="portal-admin"
|
||||
pgDB="portal-db"
|
||||
containerDB="portal-db"
|
||||
containerBackend="portal-backend"
|
||||
|
||||
dateFmt=$(date '+%Y-%m-%d')
|
||||
destination="$backupLocation/$dateFmt"
|
||||
|
||||
EnsureLocation()
|
||||
{
|
||||
rm -rf $destination
|
||||
mkdir $destination
|
||||
}
|
||||
|
||||
PostgreDump()
|
||||
{
|
||||
dbDump="$destination/$dateFmt-db.dump"
|
||||
docker exec $containerDB pg_dump \
|
||||
--username=$pgUser \
|
||||
--exclude-table=django_migrations \
|
||||
--format=custom \
|
||||
--dbname=$pgDB \
|
||||
> $dbDump
|
||||
}
|
||||
|
||||
DjangoDump()
|
||||
{
|
||||
dataDump="$destination/$dateFmt-data.json"
|
||||
docker exec $containerBackend \
|
||||
python manage.py dumpdata \
|
||||
--indent=2 \
|
||||
--exclude=admin.LogEntry \
|
||||
--exclude=sessions \
|
||||
--exclude=contenttypes \
|
||||
--exclude=auth.permission \
|
||||
> $dataDump
|
||||
gzip --force $dataDump
|
||||
}
|
||||
|
||||
EnsureLocation
|
||||
PostgreDump
|
||||
DjangoDump
|
||||
echo "Backup created at: $destination"
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# Input params
|
||||
$dataDump = "D:\DEV\backup\portal\2023-09-01\2023-09-01-db.dump"
|
||||
$target = "local-portal-db"
|
||||
$target = "dev-portal-db"
|
||||
$pgUser = "portal-admin"
|
||||
$pgDB = "portal-db"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user