From 4c8127c388b2c6b80aae691c642ee5372f8c18dc Mon Sep 17 00:00:00 2001 From: Max Mehl Date: Fri, 6 Nov 2020 15:13:37 +0100 Subject: [PATCH] fix behaviour with UTF-8 file names; make mysql backup source depend on uberspace version --- hosts.csv.sample | 2 +- uberspace-backup.sh | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hosts.csv.sample b/hosts.csv.sample index 65314a0..f922f9c 100644 --- a/hosts.csv.sample +++ b/hosts.csv.sample @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: 2019 Max Mehl # SPDX-License-Identifier: CC0-1.0 -# Username@Hostname; Path1 | Path2 | Path3 +# Username@Hostname; Path1 | Path2 | Path3; Uberspace version (default = 7) root@server; /home user@host.uberspace.de; %virtual | %mysql | /home/user/service diff --git a/uberspace-backup.sh b/uberspace-backup.sh index d99c1ce..5dbe99a 100755 --- a/uberspace-backup.sh +++ b/uberspace-backup.sh @@ -9,6 +9,9 @@ # ######################################################################## +# Set correct UTF-8 encoding (for FreeBSD jail) +export LC_ALL=en_US.UTF-8 + CURDIR=$(dirname "$(readlink -f "$0")") if [ ! -e "$CURDIR"/config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi source "$CURDIR"/config.cfg @@ -41,12 +44,13 @@ function logecho { } while read line; do - # if line is a comment, go to next line - if $(echo "$line" | grep -qE "^\s*#"); then continue; fi + # if line is a comment or blank, go to next line + if $(echo "$line" | grep -qE "^\s*(#|$)"); then continue; fi RHOST=$(echo "$line" | cut -d";" -f1 | trim) RUSER=$(echo "$RHOST" | cut -d"@" -f1) ALLRDIR=$(echo "$line" | cut -d";" -f2 | trim) + US_VERSION=$(echo "$line" | cut -d";" -f3 | trim) logecho "${RHOST}: Starting backups" @@ -80,7 +84,13 @@ while read line; do # Set Source directory, and make exception for %mysql SOURCE="${RDIR}" - if [ "${RDIR}" == "mysql" ]; then SOURCE=/mysqlbackup/latest/${RUSER}; fi + if [ "${RDIR}" == "mysql" ]; then + if [[ $US_VERSION == 6 ]]; then + SOURCE=/mysqlbackup/latest/${RUSER} + else + SOURCE=/mysql_backup/current/${RUSER} + fi + fi # Create backup destination if necessary if [ ! -e "${DEST}" ]; then mkdir -p "${DEST}"; fi