-# PostgreSQL (uncomment if you are using PostgreSQL as Nextcloud database)
-#PGPASSWORD="${dbPassword}" pg_dump "${nextcloudDatabase}" -h localhost -U "${dbUser}" -f "${backupdir}/${fileNameBackupDb}"
-echo "Done"
-echo
+ 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