#2 WIP Nextcloud db backup
This commit is contained in:
parent
0f278f2258
commit
d4663d0ce1
1 changed files with 21 additions and 0 deletions
21
backups/create_nextcloud_backup.sh
Normal file
21
backups/create_nextcloud_backup.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
# Backup script for Nextcloud in a kubernetes cluster
|
||||
|
||||
# Retrieve container names
|
||||
nextcloud_container=$( docker ps --format "{{.Names}}" | grep hugocloud-nextcloud_hugocloud-nextcloud )
|
||||
database_container=$( docker ps --format "{{.Names}}" | grep hugocloud-postgresql_hugocloud-postgresql )
|
||||
|
||||
# Abort entire script if any command fails
|
||||
set -e
|
||||
|
||||
# Turn on maintenance mode
|
||||
docker exec --user www-data "${nextcloud_container}" php occ maintenance:mode --on
|
||||
|
||||
# Database backup
|
||||
>&2 echo "Backing up database"
|
||||
docker exec "${database_container}" pg_dump "nextcloud" -cwv -h "localhost" -U "nextcloud" -f nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
|
||||
|
||||
# Turn off maintenance mode
|
||||
docker exec --user www-data "${nextcloud_container}" php occ maintenance:mode --off
|
||||
|
||||
>&2 echo "Done"
|
Loading…
Reference in a new issue