Gitbackup export facility and minor improvements.
This commit is contained in:
@@ -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.2
|
||||
# mod: The PAR_BACKUPDIR environment variable changed to PAR_SOURCEDIR.
|
||||
# mod: Introduced the SOURCEPATH environment variable to avoid hardcoding.
|
||||
# 2025-11-21 v0.1 Initial release
|
||||
|
||||
# Accepted environment variables and their defaults.
|
||||
@@ -19,7 +22,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
|
||||
BACKUPDIR=${PAR_BACKUPDIR:-""} # Folder to backup into git
|
||||
SOURCEDIR=${PAR_SOURCEDIR:-""} # Folder to backup into git
|
||||
|
||||
# Basic environment settings.
|
||||
#
|
||||
@@ -40,8 +43,8 @@ MSG_WRONGGIT="Fatal: unusable backup (git) folder"
|
||||
|
||||
# Other initialisations.
|
||||
#
|
||||
BACKUPPATH="storage/volumes/nextcloud_data"
|
||||
GITPATH="storage/backups/webcontent"
|
||||
SOURCEPATH="storage/volumes/nextcloud_data"
|
||||
YMLFILE="docker-compose.yml"
|
||||
|
||||
# Checks the dependencies.
|
||||
@@ -99,12 +102,11 @@ if [ -z "$SERVICE_BASE" -o ! -r "$SERVICE_BASE/$YMLFILE" ]; then
|
||||
echo "$MSG_MISSINGYML" >&2; exit 1
|
||||
fi
|
||||
|
||||
# Locates the folder to backup.
|
||||
# Locates the source folder.
|
||||
#
|
||||
# Maybe given as a command line parameter.
|
||||
[[ -n "$1" ]] && SOURCEDIR="$1" && shift
|
||||
# Or as an environment variable, or fallbacks to the default.
|
||||
[[ -z "$SOURCEDIR" ]] && SOURCEDIR="${BACKUPDIR:-$SERVICE_BASE/$BACKUPPATH}"
|
||||
[[ -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
|
||||
@@ -114,7 +116,6 @@ fi
|
||||
#
|
||||
# Maybe given as a command line parameter.
|
||||
[[ -n "$1" ]] && GITDIR="$1" && shift
|
||||
# Or fallbacks to the default.
|
||||
[[ -z "$GITDIR" ]] && GITDIR="$SERVICE_BASE/$GITPATH"
|
||||
# Gives up here if doesn't found.
|
||||
if [ -z "$GITDIR" -o ! -d "$("$READLINK" -e "$GITDIR")" ]; then
|
||||
|
||||
Reference in New Issue
Block a user