Jon Sud
Jon Sud

Reputation: 11641

How to convert SQL trn files to bak file?

The SQL is backup my database into many .trn files (in backup folder).

The problem is Azure Data Studio can't restore the database from .trn files. It only works with .bak file.

Is there a way to convert .trn to .bak (single file)?

Upvotes: 0

Views: 2396

Answers (1)

TT.
TT.

Reputation: 16137

You need a database backup file (typically bak extension) to go with a transaction log backup file (typically trn extension). A transaction log backup alone cannot be restored.

You can read as much in the documentation on transaction log backups:

Minimally, you must have created at least one full backup before you can create any log backups. After that, the transaction log can be backed up at any time unless the log is already being backed up.

And from Restore a Transaction Log Backup

Backups must be restored in the order in which they were created. Before you can restore a particular transaction log backup, you must first restore the following previous backups without rolling back uncommitted transactions, that is WITH NORECOVERY:

  • The full database backup and the last differential backup, if any, taken before the particular transaction log backup. Before the most recent full or differential database backup was created, the database must have been using the full recovery model or bulk-logged recovery model.
  • All transaction log backups taken after the full database backup or the differential backup (if you restore one) and before the particular transaction log backup. Log backups must be applied in the sequence in which they were created, without any gaps in the log chain.

If what you have is a database backup file and several transaction log backup files, and you really need just one backup file, you would have to restore it in a location that can accept the transaction log backup files (e.g. locally, or on your programming environment). Then from the restored database, take a database backup which you can then use as a single backup file.

Upvotes: 3

Related Questions