Accessing and Backing Up Locked WinCC Tag Logging Archive Files Without Stopping Runtime
In SIMATIC PCS 7 WinCC, active database files in TagLoggingFast and TagLoggingSlow are locked exclusively by Microsoft SQL Server (sqlservr.exe) during runtime. However, closed archive segments copied to the designated 'Backup path' in Tag Logging Archive Configuration are automatically released by SQL Server once the backup copy transaction finishes. To enable automated network scripts to back up archives to a NAS without stopping WinCC Runtime, configure your automated script to target strictly the external 'Backup' directory rather than the active live 'ArchiveManager' directory, and filter files modified earlier than the last segment rollover cycle. For automated enterprise storage, deploy SIMATIC Process Historian (PH).
Table of Contents
- Executive Summary
- WinCC Archive Manager Architecture: Fast vs Slow Circular Logs
- Why SQL Server Exclusively Locks Active Archive Segments
- The Backup Directory Mechanism vs Live Archive Directories
- WinCC Archive Backup and Storage Strategy Matrix
- Step-by-Step Configuration for Non-Disruptive NAS Backup
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
Continuous historical process recording in SIMATIC PCS 7 is managed by WinCC Tag Logging, which partitions analog and digital telemetry into TagLoggingFast (cyclic rates <= 1 min) and TagLoggingSlow (> 1 min). Plant IT security policies often dictate that long-term historical archives must be copied daily across local network shares to corporate Network-Attached Storage (NAS) or disaster recovery vaults. However, engineers authoring batch scripts (.bat, .ps1) frequently discover that their scripts abort with Windows file sharing violation errors citing The process cannot access the file because it is being used by another process. Attempting to copy active .mdf and .ldf files directly from ArchiveManager fails because Microsoft SQL Server maintains exclusive write locks. This guide details how to leverage WinCC's built-in backup path mechanism to capture released archive segments seamlessly without shutting down SCADA.
WinCC Archive Manager Architecture: Fast vs Slow Circular Logs
WinCC segments historical records into modular Microsoft SQL Server database pairs:
TagLoggingFast: High-frequency operational variables (pressures, temperatures, flow rates) logged at rates from 100 ms to 1 minute.TagLoggingSlow: Low-frequency aggregated values (daily tank levels, totalized shift production) logged at intervals > 1 minute.
Each archive consists of circular segmented buffers governed by a maximum size (e.g. 2 GB) and time horizon (e.g. 1 month).
Why SQL Server Exclusively Locks Active Archive Segments
The active circular segment currently being appended to is mounted by the Microsoft SQL Server engine (MSSQL$WINCC). To guarantee transactional ACID properties and prevent database corruption, SQL Server opens database files in exclusive mode (FILE_SHARE_READ is withheld). Windows file copy commands fail immediately when attempting to read locked active files.
The Backup Directory Mechanism vs Live Archive Directories
WinCC Archive Configuration provides an automated background archival mechanism:
- Under Tag Logging > Archive Configuration, checking Backup configuration defines a secondary storage path.
- When an active segment fills or reaches its time limit, WinCC closes the segment, detaches it, and copies a static clone into the Backup path.
- Crucially, the cloned file in the Backup directory is NOT locked by SQL Server. Network scripts targeting this folder can copy files to external NAS storage without restriction.
WinCC Archive Backup and Storage Strategy Matrix
The following table compares methodologies for backing up WinCC process archives to network storage:
<Project>\ArchiveManager\Step-by-Step Configuration for Non-Disruptive NAS Backup
Method 1: Configuring WinCC Automated Archive Backup Path
- Open the OS project in WinCC Explorer.
- In the navigation tree, expand Tag Logging > Archive Configuration.
- Right-click TagLoggingFast and select Properties.
- Check the box Activate backup configuration.
- In the Destination path field, specify a local or network directory:
D:\WinCC_Archive_Backup\TagLoggingFast\. - Repeat Steps 3-5 for TagLoggingSlow and Alarm Logging.
- Click OK to apply settings.
Method 2: Scripting the NAS Transfer from the Backup Folder
- Author a Windows PowerShell script scheduled in Windows Task Scheduler.
- Configure the script to query
D:\WinCC_Archive_Backup\rather thanArchiveManager. - Transfer files whose
LastWriteTimeis older than 2 hours to the remote NAS share (\\NAS_STORAGE\PCS7_Archives\). - Optionally, configure the script to purge local backup files older than 30 days to conserve server hard drive space.
Verification
To verify that archive files are backed up without locking errors:
- Segment Rollover Check: Trigger an archive segment swap or wait for the configured time limit. Confirm that closed
.mdfand.ldffiles populateD:\WinCC_Archive_Backup\. - Script Execution Test: Run the PowerShell backup script manually. Confirm that the script transfers files to the NAS with exit code 0 and zero sharing violation warnings.
- Archive Re-attachment Test: In WinCC Tag Logging, use the Link Archive function to link one of the NAS backup files. Confirm that historical trends render in WinCC Runtime from the backed-up data.
Limitations and Operational Precautions
- Network Share Latency: Never configure the primary WinCC live
ArchiveManagerpath across a network share. Network interruptions on the live path will crash the WinCC SQL engine. - NAS Storage Availability: If the NAS share is temporarily unreachable, WinCC retains files locally in the backup directory until network connectivity is restored.
- Regulatory Compliance: In pharmaceutical plants conforming to FDA 21 CFR Part 11, manual file copying does not guarantee an unbroken audit trail; deploy SIMATIC Process Historian.
Engineer FAQ
Can I use robocopy with the /ZB or /B switch to copy active WinCC archive files?
While robocopy backup mode bypasses NTFS permissions, it cannot bypass active exclusive write locks held by SQL Server without corrupting the file copy.
What happens to historical trends when an archive file is moved to the NAS?
Once an archive file is detached and moved, WinCC can no longer display its data unless an operator uses the 'Link Archive' tool to re-mount the segment.
How often does WinCC generate new archive segments?
The frequency depends on the parameters configured in Archive Configuration (e.g. daily, weekly, or when segment size reaches 500 MB).
Technical References
- Siemens AG: SIMATIC WinCC V7.3 System Manual - Tag Logging Configuration (Doc No. A5E34988772)
- Siemens Industry Online Support Entry ID 109780813: SIMATIC PCS 7 Long-Term Archiving Guidelines
- Microsoft Corporation: Microsoft TechNet - Working with SQL Server Database File Locks
Related Articles
- https://industrialautomation.net/search?query=wincc+tag+logging+backup+path+configuration
- https://industrialautomation.net/search?query=accessing+locked+sql+server+archive+files+wincc
- https://industrialautomation.net/search?query=process+historian+long+term+storage+nas
Related Tags
- https://industrialautomation.net/search?query=simatic-pcs7
- https://industrialautomation.net/search?query=tag-logging
- https://industrialautomation.net/search?query=archiving
- https://industrialautomation.net/search?query=sql-server