The Software Update Point (SUP) role in System Center Configuration Manager (ConfigMgr) relies on Windows Server Update Services (WSUS). The WSUS database can be hosted on a Windows Internal Database (WID). In this post I describe how to backup the WSUS database when hosted on a WID running on Windows Server 2012 R2.
Follow these steps to backup your WSUS database:
BACKUP DATABASE [SUSDB] TO DISK = N'f:\wsus_db_backup\WSUS_DB.BAK' WITH NOFORMAT, INIT, NAME = N'WSUSDB - Full Database Backup', SKIP, NOREWIND, NOUNLOAD,STATS = 10
GO
Where f:\wsus_db_backup\WSUS_DB.BAK is the full path to the backup file you want to create (you can change this).
I use the INIT argument so each backup is not appended to the same file (you can move backup files before the script runs if you want to preserve it). If you use instead use NOINIT then each backup is appended to the same backup file. You can control the overwriting of the backup file with the EXPIREDATE and RETAINDAYS arguments documented in this MSDN article.
Running the SQL Script
Run the script using the sqlcmd.exe tool using the following syntax (this is one line):
sqlcmd.exe -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i f:\WSUS_DB_Backup\backupWSUSdb.sql
Where f:\WSUS_DB_Backup\backupWSUSdb.sql is the full path to the script.
Scheduling the Script
This is how you would schedule the script in Windows Task Scheduler:
Follow these steps to backup your WSUS database:
- Obtain the SQL command-line tools (includes the sqlcmd utility) by downloading and installing the SQL Server 2012 SP1 Feature Pack on the WID server
- Download and install the ODBC driver 11 for SQL Server on the WID server
- Create the BackupWSUSdb SQL script
- Create a task in Windows Task Scheduler to run the SQL script
The BackupWSUSdb.sql script is a text file that contains the following two lines (the second line contains only "GO"):
BACKUP DATABASE [SUSDB] TO DISK = N'f:\wsus_db_backup\WSUS_DB.BAK' WITH NOFORMAT, INIT, NAME = N'WSUSDB - Full Database Backup', SKIP, NOREWIND, NOUNLOAD,STATS = 10
GO
Where f:\wsus_db_backup\WSUS_DB.BAK is the full path to the backup file you want to create (you can change this).
I use the INIT argument so each backup is not appended to the same file (you can move backup files before the script runs if you want to preserve it). If you use instead use NOINIT then each backup is appended to the same backup file. You can control the overwriting of the backup file with the EXPIREDATE and RETAINDAYS arguments documented in this MSDN article.
Running the SQL Script
Run the script using the sqlcmd.exe tool using the following syntax (this is one line):
sqlcmd.exe -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i f:\WSUS_DB_Backup\backupWSUSdb.sql
Where f:\WSUS_DB_Backup\backupWSUSdb.sql is the full path to the script.
Scheduling the Script
This is how you would schedule the script in Windows Task Scheduler:
Note: I used this Microsoft article as a reference but made changes to make it work on newer versions of SQL and Windows Server and to not append each backup to the same file.
SCCM