diff --git a/sysutils/bacula/Portfile b/sysutils/bacula/Portfile
index 4105992446..ce39ed0d4d 100644
--- a/sysutils/bacula/Portfile
+++ b/sysutils/bacula/Portfile
@@ -73,7 +73,80 @@ startupitem.stop    "\[ -r \${PID} \] && /bin/kill \$(cat \${PID})"
 notes "To use the Bacula FD client, you'll need to configure \"${prefix}/etc/bacula/bacula-fd.conf\"."
 notes-append "To use bconsole, you'll need to configure \"${prefix}/etc/bacula/bconsole.conf\"."
 
-variant client_only conflicts mysql51 mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client (bacula-fd) only" {
+set db_ports {mariadb mariadb-10.0 mariadb-10.1 mariadb-10.2 mysql51 mysql55 mysql56 mysql57 percona postgresql83 postgresql84 postgresql90 postgresql91 postgresql92 postgresql93 postgresql94 postgresql95 postgresql96 postgresql10 postgresql11 sqlite3}
+set db_variants [string map {- {}} ${db_ports}]
+proc db_variant_isset {} {
+    global db_variants
+    foreach db_variant ${db_variants} {
+        if [variant_isset ${db_variant}] {
+            return yes
+        }
+    }
+    return no
+}
+foreach db_port ${db_ports} {
+    set db_type [regsub -nocase {[^a-z].*$} ${db_port} {}]
+    set db_index [lsearch -exact ${db_ports} ${db_port}]
+    set db_variant [lindex ${db_variants} ${db_index}]
+    set db_conflicts [lreplace ${db_variants} ${db_index} ${db_index}]
+    variant ${db_variant} description "Install bacula client and server with ${db_port} backend" conflicts client_only {*}${db_conflicts} "
+        depends_lib-append      port:${db_port}
+
+        configure.args-append --enable-batch-insert
+
+        switch ${db_type} {
+            mariadb -
+            mysql -
+            percona {
+                configure.args-replace      --without-mysql --with-mysql=${prefix}/include/${db_port}/mysql
+                configure.cppflags-append   -I${prefix}/include/${db_port}/mysql
+
+                patchfiles-append           patch-configure-mysql.diff
+
+                post-patch {
+                    reinplace \"s|@@PREFIX@@|${prefix}|g\" ${worksrcpath}/configure
+                }
+
+                notes-append {
+                    To use the Bacula Director, you'll need to perform the following steps:
+                      1. create user \"bacula\" on a mysql database
+                      2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
+                      3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
+                      4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
+                      5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
+                }
+            }
+            postgresql {
+                configure.args-replace      --without-postgresql --with-postgresql
+
+                configure.env-append        PATH=${prefix}/lib/${db_port}/bin:$env(PATH)
+
+                patchfiles-append           patch-create_postgresql_database.diff
+
+                notes-append {
+                    To use the Bacula Director, you'll need to perform the following steps:
+                      1. create user \"bacula\" on a PostgreSQL database
+                      2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
+                      3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
+                      4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
+                      5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
+                }
+            }
+            sqlite {
+                configure.args-replace      --without-sqlite3 --with-sqlite3=${prefix}
+
+                notes-append {
+                    To use the Bacula Director, you'll need to perform the following steps:
+                      1. execute \"${prefix}/etc/bacula/create_bacula_database\"
+                      2. execute \"${prefix}/etc/bacula/make_bacula_tables\"
+                      3. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
+                }
+            }
+        }
+    "
+}
+
+variant client_only conflicts {*}${db_variants} description "Install bacula client (bacula-fd) only" {
     configure.args-append --enable-client-only
 }
 
@@ -98,102 +171,9 @@ variant console_bat description "Install BAT console GUI application" {
     notes-append "To use the Bacula BAT GUI, you'll need to configure \"${prefix}/etc/bacula/bat.conf\"."
 }
 
-variant mysql51 conflicts client_only mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.1 backend" {
-    depends_lib-append    port:mysql51
-    configure.args-append --with-mysql=${prefix}/include/mysql51/mysql
-    configure.args-delete --without-mysql
-    configure.args-append --enable-batch-insert
-    configure.cppflags-append   -I${prefix}/include/mysql51/mysql
-
-    patchfiles-append     patch-configure-mysql.diff
-    post-patch {
-                     reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
-    }
-    notes-append "
-       To use the Bacula Director, you'll need to perform the following steps:
-         1. create user \"bacula\" on a mysql database
-         2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
-         3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
-         4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
-         5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
-    "
-}
-
-variant mysql55 conflicts client_only mysql51 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.5 backend" {
-    depends_lib-append    port:mysql55
-    configure.args-append --with-mysql=${prefix}/include/mysql55/mysql
-    configure.args-delete --without-mysql
-    configure.args-append --enable-batch-insert
-    configure.cppflags-append   -I${prefix}/include/mysql55/mysql
-
-    patchfiles-append     patch-configure-mysql.diff
-    post-patch {
-                     reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
-    }
-    notes-append "
-       To use the Bacula Director, you'll need to perform the following steps:
-         1. create user \"bacula\" on a mysql database
-         2. execute \"${prefix}/etc/bacula/create_bacula_database -h <mysql_server> -u <db_admin_user> -p\"
-         3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <mysql_server> -u <db_admin_user> -p\"
-         4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <mysql_server> -u <db_admin_user> -p\"
-         5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
-    "
-}
-
-variant postgresql83 conflicts mysql51 mysql55 postgresql84 sqlite3 client_only description "Install bacula client and server with postgresql 8.3 backend" {
-    depends_lib-append    port:postgresql83
-    configure.args-append --with-postgresql
-    configure.args-delete --without-postgresql
-    configure.args-append --enable-batch-insert
-    configure.env-append  PATH=${prefix}/lib/postgresql83/bin:$env(PATH)
-
-    patchfiles-append     patch-create_postgresql_database.diff
-
-    notes-append "
-       To use the Bacula Director, you'll need to perform the following steps:
-         1. create user \"bacula\" on a PostgreSQL database
-         2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
-         3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
-         4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
-         5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
-    "
-}
-
-variant postgresql84 conflicts mysql51 mysql55 postgresql83 sqlite3 client_only description "Install bacula client and server with postgresql 8.4 backend" {
-    depends_lib-append    port:postgresql84
-    configure.args-append --with-postgresql
-    configure.args-delete --without-postgresql
-    configure.args-append --enable-batch-insert
-    configure.env-append  PATH=${prefix}/lib/postgresql84/bin:$env(PATH)
-
-    patchfiles-append     patch-create_postgresql_database.diff
-
-    notes-append "
-       To use the Bacula Director, you'll need to perform the following steps:
-         1. create user \"bacula\" on a PostgreSQL database
-         2. execute \"${prefix}/etc/bacula/create_bacula_database -h <postgresql-server> -U <db_admin_user>\"
-         3. execute \"${prefix}/etc/bacula/make_bacula_tables -h <postgresql-server> -U <db_admin_user>\"
-         4. execute \"${prefix}/etc/bacula/grant_bacula_privileges -h <postgresql-server> -U <db_admin_user> -p\"
-         5. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
-    "
-}
-
-variant sqlite3 conflicts client_only mysql51 mysql55 postgresql83 postgresql84 description "Install bacula client and server with sqlite 3 backend" {
-    depends_lib-append    port:sqlite3
-    configure.args-append --with-sqlite3=${prefix}
-    configure.args-delete --without-sqlite3
-    configure.args-append --enable-batch-insert
-    notes-append "
-       To use the Bacula Director, you'll need to perform the following steps:
-         1. execute \"${prefix}/etc/bacula/create_bacula_database\"
-         2. execute \"${prefix}/etc/bacula/make_bacula_tables\"
-         3. configure \"${prefix}/etc/bacula/bacula-dir.conf\" and set the catalog database settings for the bacula db user.
-    "
-}
-
 default_variants +console_bat
 
-if {![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset postgresql83] && ![variant_isset postgresql84] && ![variant_isset sqlite3]} {
+if {![db_variant_isset]} {
     default_variants-append +client_only
 } else {
     # is a server installation
