feat: nextcloud backup script

This commit is contained in:
jojo
2025-08-07 09:27:33 +02:00
parent fce313d45c
commit 3e1d191bee
4 changed files with 13 additions and 6 deletions

6
.gitignore vendored
View File

@@ -1,5 +1,3 @@
.env
.docker
# Created by https://www.toptal.com/developers/gitignore/api/archives # Created by https://www.toptal.com/developers/gitignore/api/archives
# Edit at https://www.toptal.com/developers/gitignore?templates=archives # Edit at https://www.toptal.com/developers/gitignore?templates=archives
@@ -38,4 +36,6 @@
*.txz *.txz
# End of https://www.toptal.com/developers/gitignore/api/archives # End of https://www.toptal.com/developers/gitignore/api/archives
.env
.docker
backup/

6
nextcloud/backup.sh Executable file
View File

@@ -0,0 +1,6 @@
source .env
CONTAINER_APP=app
docker compose exec $CONTAINER_APP ./occ maintenance:mode --on
docker compose exec $MYSQL_HOST sh -c "mariadb-dump --single-transaction -h $MYSQL_HOST -u $MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE > backup/nextcloud-sqlbkp_`date +'%Y%m%d'`.bak" \
&& echo "SQL dump saved"
docker compose exec $CONTAINER_APP ./occ maintenance:mode --off

View File

@@ -5,11 +5,12 @@ services:
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes: volumes:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
- ./backup:/backup
env_file: env_file:
- env - .env
app: app:
image: nextcloud image: nextcloud:stable
restart: always restart: always
ports: ports:
- 50000:80 - 50000:80
@@ -18,4 +19,4 @@ services:
volumes: volumes:
- ./nextcloud:/var/www/html - ./nextcloud:/var/www/html
env_file: env_file:
- env - .env