]>
git.p6c8.net - nextcloud-backup-restore.git/blob - setup.sh
4 # Pre defined variables
6 backupMainDir
= '/media/hdd/nextcloud_backup'
7 nextcloudFileDir
= '/var/www/nextcloud'
8 webserverUser
= 'www-data'
13 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
15 [ -z " $BACKUPMAINDIR " ] || backupMainDir
= $BACKUPMAINDIR
17 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
19 [ -z " $NEXTCLOUDFILEDIRECTORY " ] || nextcloudFileDir
= $NEXTCLOUDFILEDIRECTORY
21 read -p "Enter the webserver user (usually ${webserverUser} ). Enter an new user or press ENTER if the webserver user is ${webserverUser} : " WEBSERVERUSER
23 [ -z " $WEBSERVERUSER " ] || webserverUser
= $WEBSERVERUSER
27 echo "Backup directory: ${backupMainDir} "
28 echo "Nextcloud file directory: ${nextcloudFileDir} "
29 echo "Webserver user: ${webserverUser} "
31 read -p "Is the information correct? [y/N] " CORRECTINFO
33 if [ " $CORRECTINFO " != 'y' ] ; then
35 echo "No file has been altered."
40 sudo
-u " ${webserverUser} " php
${nextcloudFileDir} / occ config
: system
: get
" $1 "
43 # Make test call to OCC
47 echo "Error calling OCC: Please check if the information provided was correct."
49 echo "No file has been altered."
54 # Read data from OCC and write to backup/restore scripts.
59 echo "Modifying NextcloudBackup.sh and NextcloudRestore.sh to match your installation..."
63 sed -i "s@^ backupMainDir.*@ backupMainDir=' $backupMainDir '@" .
/ NextcloudBackup.sh
64 sed -i "s@^ backupMainDir.*@ backupMainDir=' $backupMainDir '@" .
/ NextcloudRestore.sh
67 sed -i "s@^nextcloudFileDir.*@nextcloudFileDir=' $nextcloudFileDir '@" .
/ NextcloudBackup.sh
68 sed -i "s@^nextcloudFileDir.*@nextcloudFileDir=' $nextcloudFileDir '@" .
/ NextcloudRestore.sh
71 nextcloudDataDir
= $
( occ_get datadirectory
)
73 sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir=' $nextcloudDataDir '@" .
/ NextcloudBackup.sh
74 sed -i "s@^nextcloudDataDir=.*@nextcloudDataDir=' $nextcloudDataDir '@" .
/ NextcloudRestore.sh
76 # Webserver service name
79 sed -i "s/^webserverUser.*/webserverUser=' $webserverUser '/" .
/ NextcloudBackup.sh
80 sed -i "s/^webserverUser.*/webserverUser=' $webserverUser '/" .
/ NextcloudRestore.sh
83 databaseSystem
= $
( occ_get dbtype
)
85 sed -i "s/^databaseSystem.*/databaseSystem=' $databaseSystem '/" .
/ NextcloudBackup.sh
86 sed -i "s/^databaseSystem.*/databaseSystem=' $databaseSystem '/" .
/ NextcloudRestore.sh
89 nextcloudDatabase
= $
( occ_get dbname
)
91 sed -i "s/^nextcloudDatabase.*/nextcloudDatabase=' $nextcloudDatabase '/" .
/ NextcloudBackup.sh
92 sed -i "s/^nextcloudDatabase.*/nextcloudDatabase=' $nextcloudDatabase '/" .
/ NextcloudRestore.sh
95 dbUser
= $
( occ_get dbuser
)
97 sed -i "s/^dbUser.*/dbUser=' $dbUser '/" .
/ NextcloudBackup.sh
98 sed -i "s/^dbUser.*/dbUser=' $dbUser '/" .
/ NextcloudRestore.sh
101 dbPassword
= $
( occ_get dbpassword
)
103 sed -i "s/^dbPassword.*/dbPassword=' $dbPassword '/" .
/ NextcloudBackup.sh
104 sed -i "s/^dbPassword.*/dbPassword=' $dbPassword '/" .
/ NextcloudRestore.sh
110 echo "IMPORTANT: Please check NextcloudBackup.sh and NextcloudRestore.sh if all variables were set correctly BEFORE running these scripts!"
patrick-canterino.de