Share via


Scripts for WSUS Import/Export

The WSUS Deployment Guide has good general guidance on how to export/import content and metadata to a disconnected network.  Here are some quick scripts that I whipped up to ease the process, as it's something that you'll probably want to do regularly.

WsusContentBackup.cmd

WsusContent.bks is required.  As is right now it will backup C:\WSUS\WsusContent to C:\WsusExport\WsusContent[date]_[time].bkf.  It will create a summary log at %userprofile%\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data.  If the initial backup creates a BKF that is too large to fit on a DVD, then you'll need to use another method to transfer the data (xcopy, robocopy, oscdimg, etc.).  However I'd recommend still running the backup the first time as it will clear the archive bit on the files so that the subsequent time this script is run, only the new content will be captured, thus the BKF will be significantly smaller.

 @echo off
set datecode=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set outdir=c:\WsusExport
set bksfile=%outdir%\wsuscontent.bks
set bkffile=%outdir%\WsusContent%datecode%.bkf

ntbackup backup @%bksfile% /j WsusContent /f %bkffile% /v:yes /l:s /m incremental

WsusContent.bks

 C:\WSUS\WsusContent\

WsusMetadataExport.cmd

Just an automated way to run the export with a unique CAB and LOG file each time.  Both files, along with the above BKF need to be transfered.

 @echo off

set datecode=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2% set outdir=c:\WsusExport set cabfile=%outdir%\WsusMetadata%datecode%.cab set logfile=%outdir%\WsusMetadata%datecode%.log

"C:\Program Files\Update Services\Tools\wsusutil.exe" export %cabfile% %logfile%

WsusMetadataImport.cmd

Import the content before running this script.  NTBackup cannot be automated to restore data so it must be done manually.  Make sure to select the Alternate Location option and point to the correct WsusContent folder (to ensure the subfolder structure is maintained).  This script requires you to give it the [date]_[time] code for the metadata you want to import. 

 @echo off
set indir=C:\WSUSImport
set cabfile=%indir%\WsusMetadata%1.cab
set logfile=%indir%\WsusMetadata%1.log

if exist %cabfile% (         if exist %logfile% (                 "C:\Program Files\Update Services\Tools\wsusutil.exe" import "%cabfile%" "%logfile%"         ) ELSE echo. && echo    ERROR: %logfile% does not exist ) ELSE echo. && echo    ERROR: %cabfile% does not exist

A few other notes:

  • Make sure the update files and language options are identical on both the export and import servers.
  • wsusutil shuts down the Update Service when it runs.
  • After the import completes wait several hours for the content and metadata to fully validate.
  • Close the Update Services console before running the export or import.

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

Comments

  • Anonymous
    January 01, 2003
    William, take a look at the script SpanWsusContent.ps1 at blogs.technet.com/.../configmgr-software-updates-on-an-isolated-network.aspx Aaron

  • Anonymous
    March 08, 2011
    Nice information, but unfortunately Windows Server 2008 does not have ntbackup installed, just wbadmin, which from most of my trolling through Technet and these blogs seems to imply that due to the new nature vhd backup, there is no way to carry out an incremental backup of the WSUSData folder. This would mean that the regular update of the Disconnected network, would require updating of the whole disk from the original 'Connected' machine and then selective recovery from the Backup each time. Not very practical, does anyone know if there another way around this that could reduce the regular amount of data required to be transferred each time to the Disconnected Network? Thanks in advance...

  • Anonymous
    August 20, 2013
    Have you updated this script to take into consideration the 2GB limit on the .cab file?