From 6ed4a0be99136ad44ef61fcfc8c647f1e7dd2d03 Mon Sep 17 00:00:00 2001 From: Patrick Canterino Date: Tue, 12 Oct 2021 20:21:59 +0200 Subject: [PATCH] No need to modify code to restore local external storage anymore --- NextcloudRestore.sh | 58 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/NextcloudRestore.sh b/NextcloudRestore.sh index abc977d..fcb6589 100644 --- a/NextcloudRestore.sh +++ b/NextcloudRestore.sh @@ -73,12 +73,15 @@ if [ "$useCompression" = true ] ; then fileNameBackupDataDir='nextcloud-datadir.tar.gz' fi -# TODO: Uncomment if you use local external storage -#fileNameBackupExternalDataDir='nextcloud-external-datadir.tar' -# -#if [ "$useCompression" = true ] ; then -# fileNameBackupExternalDataDir='nextcloud-external-datadir.tar.gz' -#fi +fileNameBackupExternalDataDir='' + +if [ ! -z "${nextcloudLocalExternalDataDir+x}" ] ; then + fileNameBackupExternalDataDir='nextcloud-external-datadir.tar' + + if [ "$useCompression" = true ] ; then + fileNameBackupExternalDataDir='nextcloud-external-datadir.tar.gz' + fi +fi fileNameBackupDb='nextcloud-db.sql' @@ -167,12 +170,13 @@ echo "Done" echo # Local external storage -# TODO: Uncomment if you use local external storage -#echo "Deleting old Nextcloud local external storage directory..." -#rm -r "${nextcloudLocalExternalDataDir}" -#mkdir -p "${nextcloudLocalExternalDataDir}" -#echo "Done" -#echo +if [ ! -z "${nextcloudLocalExternalDataDir+x}" ] ; then + echo "Deleting old Nextcloud local external storage directory..." + rm -r "${nextcloudLocalExternalDataDir}" + mkdir -p "${nextcloudLocalExternalDataDir}" + echo "Done" + echo +fi # # Restore file and data directory @@ -203,17 +207,18 @@ echo "Done" echo # Local external storage -# TODO: Uncomment if you use local external storage -#echo "$(date +"%H:%M:%S"): Restoring Nextcloud data directory..." -# -#if [ "$useCompression" = true ] ; then -# tar -I pigz -xmpf "${currentRestoreDir}/${fileNameBackupExternalDataDir}" -C "${nextcloudLocalExternalDataDir}" -#else -# tar -xmpf "${currentRestoreDir}/${fileNameBackupExternalDataDir}" -C "${nextcloudLocalExternalDataDir}" -#fi -# -#echo "Done" -#echo +if [ ! -z "${nextcloudLocalExternalDataDir+x}" ] ; then + echo "$(date +"%H:%M:%S"): Restoring Nextcloud data directory..." + + if [ "$useCompression" = true ] ; then + tar -I pigz -xmpf "${currentRestoreDir}/${fileNameBackupExternalDataDir}" -C "${nextcloudLocalExternalDataDir}" + else + tar -xmpf "${currentRestoreDir}/${fileNameBackupExternalDataDir}" -C "${nextcloudLocalExternalDataDir}" + fi + + echo "Done" + echo +fi # # Restore database @@ -268,8 +273,11 @@ echo echo "$(date +"%H:%M:%S"): Setting directory permissions..." chown -R "${webserverUser}":"${webserverUser}" "${nextcloudFileDir}" chown -R "${webserverUser}":"${webserverUser}" "${nextcloudDataDir}" -# TODO: Uncomment if you use local external storage -#chown -R "${webserverUser}":"${webserverUser}" "${nextcloudLocalExternalDataDir}" + +if [ ! -z "${nextcloudLocalExternalDataDir+x}" ] ; then + chown -R "${webserverUser}":"${webserverUser}" "${nextcloudLocalExternalDataDir}" +fi + echo "Done" echo -- 2.34.1