From dad9900740637f30137f531d162a7dbdcade2803 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 25 Jul 2018 07:36:08 -0400 Subject: nc-datadir: backup existing datadir after checks --- changelog.md | 4 +++- etc/ncp-config.d/nc-datadir.sh | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index c920cca7..25f483a9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v0.58.0](https://github.com/nextcloud/nextcloudpi/commit/4c53bf3) (2018-07-23) update to NC 13.0.5 +[v0.58.1](https://github.com/nextcloud/nextcloudpi/commit/422f4b7) (2018-07-25) nc-datadir: backup existing datadir after checks + +[v0.58.0](https://github.com/nextcloud/nextcloudpi/commit/60cfc18) (2018-07-23) update to NC 13.0.5 [v0.57.21](https://github.com/nextcloud/nextcloudpi/commit/214c187) (2018-07-23) Fixes #566 Remove redundant opcache configuration (#572) diff --git a/etc/ncp-config.d/nc-datadir.sh b/etc/ncp-config.d/nc-datadir.sh index da5059ae..38f0e05f 100644 --- a/etc/ncp-config.d/nc-datadir.sh +++ b/etc/ncp-config.d/nc-datadir.sh @@ -39,13 +39,7 @@ configure() [[ "$SRCDIR" == "$DATADIR_" ]] && { echo -e "INFO: data already there"; return 0; } - # check datadir exists - [ -d $DATADIR_ ] && { - local BKP="${DATADIR_}-$( date "+%m-%d-%y" )" - echo "INFO: $DATADIR_ is not empty. Creating backup $BKP" - mv "$DATADIR_" "$BKP" - } - + # checks local BASEDIR=$( dirname "$DATADIR_" ) [ -d "$BASEDIR" ] || { echo "$BASEDIR does not exist"; return 1; } @@ -59,6 +53,14 @@ configure() return 1 } + # backup possibly existing datadir + [ -d $DATADIR_ ] && { + local BKP="${DATADIR_}-$( date "+%m-%d-%y" )" + echo "INFO: $DATADIR_ is not empty. Creating backup $BKP" + mv "$DATADIR_" "$BKP" + } + + ## COPY cd /var/www/nextcloud sudo -u www-data php occ maintenance:mode --on -- cgit v1.2.3