diff options
author | thecalcaholic <6317548+theCalcaholic@users.noreply.github.com> | 2022-09-28 23:21:24 +0300 |
---|---|---|
committer | thecalcaholic <6317548+theCalcaholic@users.noreply.github.com> | 2022-10-03 23:44:00 +0300 |
commit | bcf8b96a902517d35e4d7fa5e73c9cee3abd1f41 (patch) | |
tree | f2461eb74013ca6919bd4fdffb4a924e80593e48 | |
parent | 16741115eeeb2b3e5006c9ebec7d50fa102cc5d2 (diff) |
nc-restore.sh: Fix dataless nc-restore deleting data directory if still in /var/www/nextcloud
Signed-off-by: thecalcaholic <6317548+theCalcaholic@users.noreply.github.com>
-rw-r--r-- | bin/ncp/BACKUPS/nc-restore.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bin/ncp/BACKUPS/nc-restore.sh b/bin/ncp/BACKUPS/nc-restore.sh index 36a158cc..375cfd94 100644 --- a/bin/ncp/BACKUPS/nc-restore.sh +++ b/bin/ncp/BACKUPS/nc-restore.sh @@ -63,8 +63,18 @@ tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || exit 1 ## RESTORE FILES echo "restore files..." +[[ -d "$NCDIR/data" ]] && { + DATA_BKP_DIR="$(mktemp -d -p "$NCDIR/.." nc-data-XXXXXX)" + mv -T "$NCDIR/data" "$DATA_BKP_DIR/" +} rm -rf "$NCDIR" mv -T "$TMPDIR"/nextcloud "$NCDIR" || { echo "Error restoring base files"; exit 1; } +if ! [[ -d "$NCDIR/data" ]] && [[ -n "$DATA_BKP_DIR" ]] +then + echo "Restoring $NCDIR/data..." + mv -T "$DATA_BKP_DIR" "$NCDIR/data" +else +fi # update NC database password to this instance sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" /var/www/nextcloud/config/config.php |