X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/blobdiff_plain/4499f0d51c387c36861a848d5082e030f7de5e5e..4e167bf7c63ced932faa536946f7b6b22b4c8546:/setup.sh diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 index fda55a6..ed29c3e --- a/setup.sh +++ b/setup.sh @@ -1,32 +1,76 @@ #!/bin/bash +# +# Bash script an easy setup of NextcloudBackup.sh and NextcloudRestore.sh +# +# Version 2.3.0 +# +# Usage: +# - call the setup.sh script +# - Enter the required information +# - You NextcloudBackup.sh and NextcloudRestore.sh scripts will be tailored to match you installation. +# +# The script is based on an installation of Nextcloud using nginx and MariaDB, see https://decatec.de/home-server/nextcloud-auf-ubuntu-server-18-04-lts-mit-nginx-mariadb-php-lets-encrypt-redis-und-fail2ban/ +# + +# +# IMPORTANT +# The setup.sh script automated the configuration for the backup/restore scripts. +# However, you should always check the backup/restore scripts BEFORE executing these! +# + +# Make sure the script exits when any command fails +set -Eeuo pipefail + # # Pre defined variables # backupMainDir='/media/hdd/nextcloud_backup' nextcloudFileDir='/var/www/nextcloud' webserverUser='www-data' +webserverServiceName='nginx' # # Gather information # -read -p "In which directory the backups should be saved (default: ${backupMainDir}). Enter a directory or press ENTER if the backup directory should be ${backupMainDir}: " BACKUPMAINDIR +clear + +echo "Enter the directory to which the backups should be saved." +echo "Default: ${backupMainDir}" +echo "" +read -p "Enter a directory or press ENTER if the backup directory should be ${backupMainDir}: " BACKUPMAINDIR [ -z "$BACKUPMAINDIR" ] || backupMainDir=$BACKUPMAINDIR +clear -read -p "Enter the path to the Nextcloud file directory (usually ${nextcloudFileDir}). Enter a directory or press ENTER if the file directory is ${nextcloudFileDir}: " NEXTCLOUDFILEDIRECTORY +echo "Enter the path to the Nextcloud file directory." +echo "Usually: ${nextcloudFileDir}" +echo "" +read -p "Enter a directory or press ENTER if the file directory is ${nextcloudFileDir}: " NEXTCLOUDFILEDIRECTORY [ -z "$NEXTCLOUDFILEDIRECTORY" ] || nextcloudFileDir=$NEXTCLOUDFILEDIRECTORY +clear -read -p "Enter the webserver user (usually ${webserverUser}). Enter an new user or press ENTER if the webserver user is ${webserverUser}: " WEBSERVERUSER +echo "Enter the webserver user." +echo "Usually: ${webserverUser}" +echo "" +read -p "Enter an new user or press ENTER if the webserver user is ${webserverUser}: " WEBSERVERUSER [ -z "$WEBSERVERUSER" ] || webserverUser=$WEBSERVERUSER +clear +echo "Enter the webserver service name." +echo "Usually: nginx or apache2" echo "" -echo "" +read -p "Enter an new webserver service name or press ENTER if the webserver service name is ${webserverServiceName}: " WEBSERVERSERVICENAME + +[ -z "$WEBSERVERSERVICENAME" ] || webserverServiceName=$WEBSERVERSERVICENAME +clear + echo "Backup directory: ${backupMainDir}" echo "Nextcloud file directory: ${nextcloudFileDir}" echo "Webserver user: ${webserverUser}" +echo "Webserver service name: ${webserverServiceName}" echo "" read -p "Is the information correct? [y/N] " CORRECTINFO @@ -45,7 +89,7 @@ occ_get datadirectory if [ $? -ne 0 ]; then echo "Error calling OCC: Please check if the information provided was correct." - echo "ABORTING!" + echo "ABORTING!" echo "No file has been altered." exit 1 fi @@ -74,6 +118,8 @@ sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir='$nextcloudDataDir'@" ./Nextclou sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir='$nextcloudDataDir'@" ./NextcloudRestore.sh # Webserver service name +sed -i "s/^webserverServiceName.*/webserverServiceName='$webserverServiceName'/" ./NextcloudBackup.sh +sed -i "s/^webserverServiceName.*/webserverServiceName='$webserverServiceName'/" ./NextcloudRestore.sh # Webserver user sed -i "s/^webserverUser.*/webserverUser='$webserverUser'/" ./NextcloudBackup.sh @@ -82,6 +128,11 @@ sed -i "s/^webserverUser.*/webserverUser='$webserverUser'/" ./NextcloudRestore.s # Database system databaseSystem=$(occ_get dbtype) +# PostgreSQL is identified as pgsql +if [ "${databaseSystem,,}" = "pgsql" ]; then + databaseSystem='postgresql'; +fi + sed -i "s/^databaseSystem.*/databaseSystem='$databaseSystem'/" ./NextcloudBackup.sh sed -i "s/^databaseSystem.*/databaseSystem='$databaseSystem'/" ./NextcloudRestore.sh