9

Many well-known backup utilities for Windows use the Volume Shadow Copy Service built in to newer versions of windows to create a point-in-time snapshot of the disk in order to safely back up open files.

But how well does this mechanism play with SQL Server? I know that an SQL Server VSS Writer exists to help backup systems interoperate with SQL Server, but not all backup systems know about SQL Server and take advantage the backup-related API that it provides.

So my question is, what about the programs that don't know anything about SQL Server?

They presumably get a point-in-time snapshot of the MDF and LDF files as they existed at one single instant. And presumably the SQL Server data format is robust enough that such a snapshot would be guaranteed to be consistent and usable.

Is that the way things work, or am I missing something? Are there "gotchas" about using such a backup mechanism, or would I be safe?

tylerl
  • 14,885
  • 7
  • 49
  • 71

4 Answers4

8

Short answer: they don't play very well together unless you've got SQL server configured appropriately (and even then I wouldn't recommend it).

There's a lot of information about VSS & MSSQL playing together here:
MSKB919023: SQL Server 2005 connectivity and Volume Shadow Copy Service (VSS).

One word of warning though:

presumably the SQL Server data format is robust enough that such a snapshot would be guaranteed to be consistent and usable

That's a big assumption, and one that's not always safe to make unfortunately. That's why your MSSQL maintenance plans are essential to ensuring you can recover from disasters.

StackzOfZtuff
  • 1,754
  • 12
  • 21
Mark Henderson
  • 68,316
  • 31
  • 175
  • 255
  • That link is no more. Perhaps this one is an replacement: https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-vss-writer-backup-guide?view=sql-server-ver15 – DBJDBJ Feb 27 '21 at 06:36
6

You never backup MDF and LDF files.

You run backups (plans, SQL, SMO, whatever) then backup these backup files.

Frankly, I don't get a fig what any vendor says about VSS. I also dislike any vendor that has a SQL Server plugin for backups. You use SQL Server native backups only

FYI: you also exclude MDFs and LDFs from virus scanning too.

gbn
  • 6,009
  • 1
  • 17
  • 21
2

If you don't have software that has a SQL "option" then:

Create SQL maintenance plans or scheduled Backup jobs for the databases, dump them to disk, then backup the server. Or when you dump them, dump them straight to your disk-to-disk backup location if you have one.

TheCleaner
  • 32,352
  • 26
  • 126
  • 188
2

The main problem with VSS backup is caused by caching in sql server.

The current state on your disk does not always contain all database changes. Backupsoftware must be aware of this to ensure that sql server write all of it's caches before you take am snapshot.

Having that said: the safest method is still backuping up in sql management/with sql server tools.

And you should exclude all sql server data and backup files from virusscanners (.bak, .mdf, .ldf).

Andreas Rehm
  • 841
  • 6
  • 11
  • 3
    The whole purpose of the VSS Requestor\Writer architecture is to ensure that the relying application (e.g. your Backup app) can instruct the owner (SQL Server\Exchange etc) to flush all cached data and open transactions, then flush the OS disk cache before making the snapshot. Whether it works well is another issue but the architecture does as much as it can to ensure the files are consistent. – Helvick Sep 18 '10 at 16:05
  • 2
    um, no. unless you've made a crazy configuration change, once a transaction is committed, it's on disk. there is nothing committed in cache that is not also committed on disk. – longneck Nov 05 '12 at 20:09