-# 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 "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