-echo "Backup Nextcloud database..."
-mysqldump --single-transaction -h localhost -u "${dbUser}" -p"${dbPassword}" "${nextcloudDatabase}" > "${backupdir}/${fileNameBackupDb}"
-echo "Done"
+if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ]; then
+ echo "$(date +"%H:%M:%S"): Backup Nextcloud database (MySQL/MariaDB)..."
+
+ if ! [ -x "$(command -v mysqldump)" ]; then
+ errorecho "ERROR: MySQL/MariaDB not installed (command mysqldump not found)."
+ errorecho "ERROR: No backup of database possible!"
+ else
+ mysqldump --single-transaction -h localhost -u "${dbUser}" -p"${dbPassword}" "${nextcloudDatabase}" > "${backupdir}/${fileNameBackupDb}"
+ fi
+
+ echo "Done"
+ echo
+elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then
+ echo "$(date +"%H:%M:%S"): Backup Nextcloud database (PostgreSQL)..."
+
+ if ! [ -x "$(command -v pg_dump)" ]; then
+ errorecho "ERROR: PostgreSQL not installed (command pg_dump not found)."
+ errorecho "ERROR: No backup of database possible!"
+ else
+ PGPASSWORD="${dbPassword}" pg_dump "${nextcloudDatabase}" -h localhost -U "${dbUser}" -f "${backupdir}/${fileNameBackupDb}"
+ fi
+
+ echo "Done"
+ echo
+fi