]> git.p6c8.net - nextcloud-backup-restore.git/blobdiff - NextcloudRestore.sh
„LICENSE“ ändern
[nextcloud-backup-restore.git] / NextcloudRestore.sh
index 6f983fb57b4c9236d5a917e8faa4b6228b39ebaa..90ec5453b015d059d54529f3c079ffc679368c28 100644 (file)
@@ -3,7 +3,7 @@
 #
 # Bash script for restoring backups of Nextcloud.
 #
 #
 # Bash script for restoring backups of Nextcloud.
 #
-# Version 1.1.1
+# Version 2.0.0
 #
 # Usage:
 #   - With backup directory specified in the script: ./NextcloudRestore.sh <BackupName> (e.g. ./NextcloudRestore.sh 20170910_132703)
 #
 # Usage:
 #   - With backup directory specified in the script: ./NextcloudRestore.sh <BackupName> (e.g. ./NextcloudRestore.sh 20170910_132703)
@@ -111,7 +111,7 @@ if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ];
         errorecho "Cancel restore"
         exit 1
     fi
         errorecho "Cancel restore"
         exit 1
     fi
-elif [ "${databaseSystem,,}" = "postgresql" ]; then
+elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then
     if ! [ -x "$(command -v psql)" ]; then
                errorecho "ERROR: PostgreSQL not installed (command psql not found)."
                errorecho "ERROR: No restore of database possible!"
     if ! [ -x "$(command -v psql)" ]; then
                errorecho "ERROR: PostgreSQL not installed (command psql not found)."
                errorecho "ERROR: No restore of database possible!"
@@ -206,7 +206,7 @@ if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ];
     mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
     # TODO: Use this if the database from the backup DOES NOT use UTF8 with multibyte support (e.g. for emoijs in filenames):
     #mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase}"
     mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
     # TODO: Use this if the database from the backup DOES NOT use UTF8 with multibyte support (e.g. for emoijs in filenames):
     #mysql -h localhost -u "${dbUser}" -p"${dbPassword}" -e "CREATE DATABASE ${nextcloudDatabase}"
-elif [ "${databaseSystem,,}" = "postgresql" ]; then
+elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then
     sudo -u postgres psql -c "CREATE DATABASE ${nextcloudDatabase} WITH OWNER ${dbUser} TEMPLATE template0 ENCODING \"UTF8\";"
 fi
 
     sudo -u postgres psql -c "CREATE DATABASE ${nextcloudDatabase} WITH OWNER ${dbUser} TEMPLATE template0 ENCODING \"UTF8\";"
 fi
 
@@ -217,7 +217,7 @@ echo "Restoring backup DB..."
 
 if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ]; then
        mysql -h localhost -u "${dbUser}" -p"${dbPassword}" "${nextcloudDatabase}" < "${currentRestoreDir}/${fileNameBackupDb}"
 
 if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ]; then
        mysql -h localhost -u "${dbUser}" -p"${dbPassword}" "${nextcloudDatabase}" < "${currentRestoreDir}/${fileNameBackupDb}"
-elif [ "${databaseSystem,,}" = "postgresql" ]; then
+elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then
        sudo -u postgres psql "${nextcloudDatabase}" < "${currentRestoreDir}/${fileNameBackupDb}"
 fi
 
        sudo -u postgres psql "${nextcloudDatabase}" < "${currentRestoreDir}/${fileNameBackupDb}"
 fi
 

patrick-canterino.de