The community edition of Bacula doesn’t have a SQL plugin but that doesn’t mean you can’t make backups of your SQL database into .bak files and then back up those .bak files to your Bacula system.
Here is how I accomplish this:
I created a directory on the SQL server called C:\DatabaseBackups and another directory inside that one called \scripts. In the scripts directory, I created a batch file named sql.bat and it contains the following script:
sqlcmd -S .\DATABASE1 -Q “BACKUP DATABASE DB2 TO DISK = ‘C:\DatabaseBackups\DB2.bak’ WITH INIT, NAME = N’Automatic back up of database’, STATS = 1”
sqlcmd -S .\DATABASE1 -Q “BACKUP DATABASE DB3 TO DISK = ‘C:\DatabaseBackups\DB3.bak’ WITH INIT, NAME = N’Automatic back up of database’, STATS = 1”
exit
This script deletes the old backups created the last time the job ran and then recreates new ones. Depending on the size of your databases, this could take a little while to run but Bacula will wait until the script finishes before it tries to backup these files.
Run the script using Client Run Before Job
In the job settings, you will need to add the Client Run Before Job option and select the location of the batch file to run. In my case, the job config looks like this:
Once the backup is complete, the message that’s received will contain the progress of the database backup as well as any other messages. The output looks like this: