postgres backup & update script
This commit is contained in:
parent
14c4ddc7f7
commit
ee596da610
3 changed files with 40 additions and 18 deletions
|
@ -1,17 +1,11 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
DB_FILE="db/ciso-assistant.sqlite3"
|
#DB_FILE="db/ciso-assistant.sqlite3"
|
||||||
BACKUP_FILE="ciso-assistant-backup.sqlite3"
|
#BACKUP_FILE="ciso-assistant-backup.sqlite3"
|
||||||
|
|
||||||
# Backup the database
|
# Backup the database
|
||||||
if [ ! -f "$DB_FILE" ]; then
|
/usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup
|
||||||
echo "Error: No database found, please initialize CISO Assistant first"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
cp "$DB_FILE" "$BACKUP_FILE"
|
|
||||||
echo "Backup of the database created in $BACKUP_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Stop and clean the containers
|
# Stop and clean the containers
|
||||||
docker compose rm -fs
|
docker compose rm -fs
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
cd /opt/cisoas/
|
|
||||||
./update-ciso-assistant.sh enterprise
|
VERSION=${1:-community}
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$VERSION" = "enterprise" ]; then
|
||||||
|
BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-backend:latest"
|
||||||
|
FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-enterprise-frontend:latest"
|
||||||
|
else
|
||||||
|
BACKEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/backend:latest"
|
||||||
|
FRONTEND_IMAGE="ghcr.io/intuitem/ciso-assistant-community/frontend:latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Update of the version : $VERSION"
|
||||||
|
|
||||||
|
# Backup the database
|
||||||
|
|
||||||
|
echo "Backing up database"
|
||||||
|
|
||||||
|
/opt/cisoas ❯ /usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup
|
||||||
|
|
||||||
|
# Stop the containers
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
# Remove the images
|
||||||
|
docker rmi "$BACKEND_IMAGE" "$FRONTEND_IMAGE" 2>/dev/null
|
||||||
|
|
||||||
|
# Start the containers
|
||||||
|
docker compose up -d
|
||||||
|
echo "CISO assistant updated successfully"
|
|
@ -64,13 +64,6 @@ class net::cisoassistant_test ($ciso_service_name='',
|
||||||
content => file('net/cisoassistant/update-cisoas-enterprise_test.sh'),
|
content => file('net/cisoassistant/update-cisoas-enterprise_test.sh'),
|
||||||
} ->
|
} ->
|
||||||
|
|
||||||
file { '/opt/cisoas/update-ciso-assistant.sh':
|
|
||||||
mode => '0744',
|
|
||||||
owner => 'root',
|
|
||||||
group => 'root',
|
|
||||||
content => file('net/cisoassistant/update-ciso-assistant.sh'),
|
|
||||||
} ->
|
|
||||||
|
|
||||||
file { '/opt/cisoas/Caddyfile':
|
file { '/opt/cisoas/Caddyfile':
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => 'root',
|
group => 'root',
|
||||||
|
@ -85,4 +78,12 @@ class net::cisoassistant_test ($ciso_service_name='',
|
||||||
ok_criteria => ['exit_status=0', 'max_age=10d'],
|
ok_criteria => ['exit_status=0', 'max_age=10d'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sunet::scriptherder::cronjob { 'postgres_backup':
|
||||||
|
cmd => '/usr/bin/docker compose -f /opt/cisoas/docker-compose.yml exec -T postgres /usr/local/bin/backup',
|
||||||
|
minute => '34',
|
||||||
|
hour => '3',
|
||||||
|
ok_criteria => ['exit_status=0', 'max_age=25h'],
|
||||||
|
warn_criteria => ['exit_status=0', 'max_age=49h'],
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue