In Nextcloud recipe the storage_backup now excludes the documents if the storage_gitbackup is active.

This commit is contained in:
2026-02-17 20:06:44 +01:00
parent 22fac32e46
commit 7799e7a11f
2 changed files with 11 additions and 2 deletions

BIN
.metadata

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#
# A service script to backup the relevant user's storage (data folder)
# A service script to backup the relevant user's storage (apps, data, themes)
# of a docker-composed Nextcloud instance. Creates a tarball in
# $BASE_DIR/storage/backups/tarballs folder (by default). An optional
# parameter may change the target folder.
@@ -9,6 +9,9 @@
#
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL 3+ https://www.gnu.org/licenses/gpl-3.0.en.html
# 2026-02-07 v0.2
# new: Excludes the documents if the storage_gitbackup is active.
# mod: custom_apps and themes folders have been added.
# 2025-11-24 v0.1 Initial version.
# Accepted environment variables and their defaults.
@@ -28,6 +31,7 @@ MSG_NOLOCATE="Cannot locate the Nextcloud container."
# Other initialisations.
#
BACKUPDIR="storage/backups/tarballs" # Folder to dump within
GITBACKUP="storage_gitbackup.sh" # Git backup utility
SERVICENAME="nextcloud" # The composed Nextcloud service
USER=${USER:-LOGNAME} # Fix for cron enviroment only
YMLFILE="docker-compose.yml"
@@ -112,11 +116,16 @@ NCCONTAINER="$("$DOCKER" inspect -f '{{.Name}}' $(cd "$BASE_DIR"; "$DOCKER_COMPO
# Gives up here if failed.
if [ -z "$NCCONTAINER" ]; then echo "$MSG_NOLOCATE" >&2; exit 1; fi
# Excludes the documents if the GITBACKUP is active.
DOCUMENTS="data"
[[ -n $(which "$GITBACKUP") ]] && DOCUMENTS="" # it is an executable somewhere in the path
[[ -x "$SCRPATH/$GITBACKUP" ]] && DOCUMENTS="" # it is an executable in the current directory
# Tries the FS backup.
if [ -w "$BACKUPDIR" ]; then
BACKUP_NAME=$NCCONTAINER.$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME")
"$DOCKER" exec $NCCONTAINER sh \
-c "cd /var/www/html; tar cz data" \
-c "cd /var/www/html; tar cz custom_apps $DOCUMENTS themes" \
> "$BACKUPDIR/$BACKUP_NAME.tgz" 2>>"$BACKUPDIR/$BACKUP_NAME.log"
fi