The default backup process for Liquibase Enterprise SqlServer databases uses the following backup logic:
...
Customers whose database configuration does not support WITH INIT
may see an error such as:
The backup cannot be performed because 'INIT' was requested after the media was formatted with an incompatible structure. To append to this media set, either omit 'INIT' or specify 'FORMAT'. Alternatively, you can create a new media set by using WITH FORMAT in your BACKUP statement. If you use WITH FORMAT on an existing media set, all its backup sets will be overwritten.
Instructions
Download the custom script here. This script has modified logic:
Uses the following backup command including
WITH NOINIT
logic:Code Block BACKUP DATABASE [${databaseDef.databaseName}] TO DISK = N'${filename}' WITH NOINIT, COPY_ONLY, NOUNLOAD, NAME = N'${databaseDef.databaseName} backup', NOSKIP, STATS = 10, NOFORMAT
Includes code to delete any existing backups prior to taking a new one:
Code Block def connection def sql (connection, sql) = scriptUtils.openConnection(daticalDBHelper, databaseDef) boolean success = scriptUtils.tryExecuteSql(sql, "EXECUTE master.dbo.xp_delete_file 0,N'${fullFilename}'", "Deleting existing backup")
Make any other adjustments necessary to the custom script. For example, you can make modifications to
SKIP
media options or includeNO_COMPRESSION
.
The code to delete any existing backups requires SYSADMIN role. Ensure your Liquibase user has the SYSADMIN role.
There are two ways to house the custom script. The script can be housed per project (Method A) or in the Liquibase Enterprise installation directory (Method B).
Method A - house script per project
Create a folder in the DDB project repo called BackupRestoreScripts
Place custom script in this folder
In the deployPackager.properties add
Code Block extensionsPath=./BackupRestoreScripts databaseBackupRestoreMethod=CustomBackupRestoreSqlServer
Method B - house script in the Liquibase installation directory
Place script in the
<Liquibase Enterprise install directory>/repl/scripts/extensions
directory.In the deployPackager.properties add
Code Block databaseBackupRestoreMethod=CustomBackupRestoreSqlServer
...