Fix: “BACKUP LOG cannot be performed because there is no current database backup.” in SQL Server/SQL Edge

If you’re trying to back up the transaction logs in a SQL Server or SQL Edge database, but you get an error that states BACKUP LOG cannot be performed because there is no current database backup, you’ll need to perform at least one full backup of the database before you attempt to back up the transaction logs.

The Error

Here’s an example of code that results in the error:

BACKUP LOG Music 
TO DISK = '/var/opt/mssql/backups/Music.trn';

Result:

Msg 4214, Level 16, State 1, Line 1
BACKUP LOG cannot be performed because there is no current database backup.

The Cause

This error occurs whenever you try to back up the transaction log without first having run a full database backup.

You must have created at least one full backup before you can create any log backups.

The Solution

All you need to do is create at least one full database backup before trying to back up the log files.

Example:

BACKUP DATABASE Music 
    TO DISK = '/var/opt/mssql/backups/Music.bak' 
    WITH FORMAT;

Now the transaction logs can be backed up as required:

BACKUP LOG Music 
TO DISK = '/var/opt/mssql/backups/Music.trn';

Result:

Processed 3 pages for database 'Music', file 'Music_log' on file 1.