Gitbackup export facility and minor improvements.

This commit is contained in:
2026-04-12 19:15:39 +02:00
parent c6c4d2794f
commit bb796024e3
9 changed files with 572 additions and 21 deletions
@@ -11,6 +11,9 @@
#
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-04-12 v0.4
# mod: The PAR_BACKUPDIR environment variable changed to PAR_SOURCEDIR.
# mod: Introduced the SOURCEPATH environment variable to avoid hardcoding.
# 2025-05-21 v0.3.1
# fix: Wrong variable name (BASE_DIR instead of SERVICE_BASE) in a check.
# 2025-05-20 v0.3
@@ -27,7 +30,7 @@ BOTEMAIL=${BOTEMAIL:-"backupbot@example.com"} # Git repo owner's email (fake)
BOTNAME=${BOTNAME:-"Backup Bot"} # Git repo owner's name (fake)
SERVICE_BASE=${PAR_BASEDIR:-""} # Corresponding service's base
GITDIR=${PAR_GITDIR:-""} # Folder containing .git
SOURCEDIR=${PAR_BACKUPDIR:-""} # Folder to backup into git
SOURCEDIR=${PAR_SOURCEDIR:-""} # Folder to backup into git
# Basic environment settings.
#
@@ -49,6 +52,7 @@ MSG_WRONGGIT="Fatal: unusable backup (git) folder"
# Other initialisations.
#
GITPATH="storage/backups/webcontent"
SOURCEPATH="storage/volumes/wordpress_html"
YMLFILE="docker-compose.yml"
# Checks the dependencies.
@@ -105,14 +109,12 @@ TEST_DIR="$("$DIRNAME" "$TEST_DIR")"
if [ -z "$SERVICE_BASE" -o ! -r "$SERVICE_BASE/$YMLFILE" ]; then
echo "$MSG_MISSINGYML" >&2; exit 1
fi
# Sets the absolute paths.
BACKUPDIR="${PAR_BACKUPDIR:-$SERVICE_BASE/$BACKUPDIR}"
# Locates the source folder.
#
# Maybe given as a command line parameter.
[[ -n "$1" ]] && SOURCEDIR="$1" && shift
[[ -z "$SOURCEDIR" ]] && SOURCEDIR="$SERVICE_BASE/storage/volumes/wordpress_html"
[[ -z "$SOURCEDIR" ]] && SOURCEDIR="$SERVICE_BASE/$SOURCEPATH"
# Gives up here if doesn't found.
if [ -z "$SOURCEDIR" -o ! -d "$("$READLINK" -e "$SOURCEDIR")" ]; then
echo "$MSG_MISSINGSOURCE $SOURCEDIR"; exit 1