]>
git.p6c8.net - nextcloud-backup-restore.git/blob - setup.sh
9af4338adfa3e58c30450c52fe2516bf111835ff
4 # Bash script an easy setup of NextcloudBackup.sh and NextcloudRestore.sh
9 # - call the setup.sh script
10 # - Enter the required information
11 # - You NextcloudBackup.sh and NextcloudRestore.sh scripts will be tailored to match you installation.
13 # 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/
18 # The setup.sh script automated the configuration for the backup/restore scripts.
19 # However, you should always check the backup/restore scripts BEFORE executing these!
23 # Pre defined variables
25 backupMainDir
= '/media/hdd/nextcloud_backup'
26 nextcloudFileDir
= '/var/www/nextcloud'
27 webserverUser
= 'www-data'
32 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
34 [ -z " $BACKUPMAINDIR " ] || backupMainDir
= $BACKUPMAINDIR
36 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
38 [ -z " $NEXTCLOUDFILEDIRECTORY " ] || nextcloudFileDir
= $NEXTCLOUDFILEDIRECTORY
40 read -p "Enter the webserver user (usually ${webserverUser} ). Enter an new user or press ENTER if the webserver user is ${webserverUser} : " WEBSERVERUSER
42 [ -z " $WEBSERVERUSER " ] || webserverUser
= $WEBSERVERUSER
46 echo "Backup directory: ${backupMainDir} "
47 echo "Nextcloud file directory: ${nextcloudFileDir} "
48 echo "Webserver user: ${webserverUser} "
50 read -p "Is the information correct? [y/N] " CORRECTINFO
52 if [ " $CORRECTINFO " != 'y' ] ; then
54 echo "No file has been altered."
59 sudo
-u " ${webserverUser} " php
${nextcloudFileDir} / occ config
: system
: get
" $1 "
62 # Make test call to OCC
66 echo "Error calling OCC: Please check if the information provided was correct."
68 echo "No file has been altered."
73 # Read data from OCC and write to backup/restore scripts.
78 echo "Modifying NextcloudBackup.sh and NextcloudRestore.sh to match your installation..."
82 sed -i "s@^ backupMainDir.*@ backupMainDir=' $backupMainDir '@" .
/ NextcloudBackup.sh
83 sed -i "s@^ backupMainDir.*@ backupMainDir=' $backupMainDir '@" .
/ NextcloudRestore.sh
86 sed -i "s@^nextcloudFileDir.*@nextcloudFileDir=' $nextcloudFileDir '@" .
/ NextcloudBackup.sh
87 sed -i "s@^nextcloudFileDir.*@nextcloudFileDir=' $nextcloudFileDir '@" .
/ NextcloudRestore.sh
90 nextcloudDataDir
= $
( occ_get datadirectory
)
92 sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir=' $nextcloudDataDir '@" .
/ NextcloudBackup.sh
93 sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir=' $nextcloudDataDir '@" .
/ NextcloudRestore.sh
95 # Webserver service name
98 sed -i "s/^webserverUser.*/webserverUser=' $webserverUser '/" .
/ NextcloudBackup.sh
99 sed -i "s/^webserverUser.*/webserverUser=' $webserverUser '/" .
/ NextcloudRestore.sh
102 databaseSystem
= $
( occ_get dbtype
)
104 sed -i "s/^databaseSystem.*/databaseSystem=' $databaseSystem '/" .
/ NextcloudBackup.sh
105 sed -i "s/^databaseSystem.*/databaseSystem=' $databaseSystem '/" .
/ NextcloudRestore.sh
108 nextcloudDatabase
= $
( occ_get dbname
)
110 sed -i "s/^nextcloudDatabase.*/nextcloudDatabase=' $nextcloudDatabase '/" .
/ NextcloudBackup.sh
111 sed -i "s/^nextcloudDatabase.*/nextcloudDatabase=' $nextcloudDatabase '/" .
/ NextcloudRestore.sh
114 dbUser
= $
( occ_get dbuser
)
116 sed -i "s/^dbUser.*/dbUser=' $dbUser '/" .
/ NextcloudBackup.sh
117 sed -i "s/^dbUser.*/dbUser=' $dbUser '/" .
/ NextcloudRestore.sh
120 dbPassword
= $
( occ_get dbpassword
)
122 sed -i "s/^dbPassword.*/dbPassword=' $dbPassword '/" .
/ NextcloudBackup.sh
123 sed -i "s/^dbPassword.*/dbPassword=' $dbPassword '/" .
/ NextcloudRestore.sh
129 echo "IMPORTANT: Please check NextcloudBackup.sh and NextcloudRestore.sh if all variables were set correctly BEFORE running these scripts!"
patrick-canterino.de