Share via


Backing up WSUS database via the command line

How to backup SUSDB utilizing SQLCMD on a WID (Windows Internal Database).

You will need the following two downloads installed on your server for sqlcmd.exe to work.

Microsoft SQL Server 2005 Command Line Query Utility:

http://download.microsoft.com/download/4/4/D/44DBDE61-B385-4FC2-A67D-48053B8F9FAD/SQLServer2005_SQLCMD.msi

Microsoft SQL Native Client:

http://go.microsoft.com/fwlink/?LinkId=54583

Create a .sql script using the following text and substitute the c:\temp\susdb.bak for wherever you want your backup to reside.

BACKUP DATABASE [SUSDB] TO DISK = N'c:\temp\susdb.bak' WITH NOFORMAT, NOINIT, NAME = N'SUSDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10

GO

Save the script as c:\temp\susdb.sql

Run the following from the command line:

sqlcmd -S \.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i c:\temp\susdb.sql

Specify the correct location for where you have your .sql script located.