Backing Up PCS7 WinCC Central Archive Server SQL Databases

David Krause10 min read
SCADA ConfigurationSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The Central Archive Server (CAS) in a Siemens PCS 7 / WinCC installation stores process values, alarms, and long-term logs in Microsoft SQL Server databases. A SQL Server Maintenance Plan is the conventional mechanism to schedule full, differential, and transaction-log backups, but the plan must be aware of which databases legitimately belong to the CAS and which are orphaned remnants from prior host renames, OS images, or project re-compilations. Backing up every database indiscriminately - including stale ones - is the single most common cause of intermittent maintenance-plan failures on a CAS host.

This reference documents the database topology of a WinCC/PCS 7 CAS, the identification procedure for live versus orphaned instances, the safe construction of a Maintenance Plan, and the verification checks that confirm a restore would be functional. All SQL Server procedures below reference the official Microsoft Learn documentation at Back up and restore of SQL Server databases.

Central Archive Server Database Topology

The CAS is a WinCC component that runs as a SQL Server instance and serves as a redundant, long-term store for runtime data. Multiple databases typically exist on a single host:

Database Logical role Source
WinCC_CC_<ProcessName>_<Timestamp> Runtime archive / tag logging Created by WinCC Runtime on first start
WinCC_Alarm_<ProcessName>_<Timestamp> Long-term alarm archive Created by WinCC Alarm Logging service
CC_ProcessValueArchive_... Compressed process-value archive (CAS) Created automatically by CAS service
Master, Model, Msdb, Tempdb System databases (do NOT back up Tempdb) SQL Server installation media
Critical: The literal database name in SQL Server Management Studio (SSMS) is suffixed with the WinCC host name (e.g. WinCC_CC_PROCESS_A_14_03_2022_10_15_22). Renaming the host therefore leaves the OLD database on the SQL instance while the new WinCC runtime creates a NEW database - both physically coexist until cleaned up.

Identifying Required vs. Orphaned Databases

Before configuring any Maintenance Plan, enumerate the databases that are actually in use by the live WinCC/PCS 7 project.

  1. Open SQL Server Management Studio and connect to the CAS instance (default instance name: WINCC or PCName\WINCC).
  2. Expand Databases → System Databases and then Databases.
  3. For each WinCC_* or CC_* database, run:
    SELECT name, database_id, create_date, compatibility_level,
           DATABASEPROPERTYEX(name, 'IsOnline') AS IsOnline,
           DATABASEPROPERTYEX(name, 'Updateability') AS UpdateMode
    FROM sys.databases
    WHERE name LIKE 'WinCC%' OR name LIKE 'CC%'
    ORDER BY create_date DESC;
  4. Cross-reference the result against the live project path. Open the active WinCC project on the CAS and read the database identifier it expects from the project's Computer properties → Database dialog.
  5. Mark every database that does not match the current project or current computer name as a candidate for deletion, not backup.

Root Cause: Why "Back Up Everything" Fails

The recurring failure pattern reported by integrators is rooted in the SQL Server Maintenance Plan Wizard interpreting the inclusion list as a snapshot at run time. If a database referenced in the plan no longer exists at execution time (because it was an orphan and was removed, or because the Maintenance Plan was authored against a database that has since been dropped), sqlmaint.exe records an error and may fail the surrounding job step.

Common precursor events that introduce orphan databases:

  • OS image / system download on the CAS host restores an older disk state. WinCC re-initialises and creates a fresh database; the older database remains on the SQL instance until manually removed.
  • Rename of the ES or CAS computer. WinCC embeds the computer name into the database name; renaming the host without re-projecting the database leaves the old instance behind (typically visible as newPCname\WinCC in the WinCC Explorer even though SSMS still shows the old WinCC_* database).
  • PCS 7 project compilation that adds tags, alarms, or archive segments. WinCC Runtime does not always require a new database on a compilation-only change, but significant schema changes (e.g. new archive segments, name changes) can trigger creation of an additional database alongside the existing one.
  • Manual detach/attach operations by administrators unfamiliar with WinCC.
Verification of a healthy instance: The number of WinCC_* databases on a healthy single-project CAS should equal the number of WinCC Runtime archives you have explicitly configured (usually one for tag logging, one for alarm logging). If you see more than that, investigate before relying on backups.

Building a Safe Maintenance Plan

The Maintenance Plan Wizard in SQL Server Management Studio builds a job that ultimately calls sqlmaint.exe with a switch list. To avoid the failure mode above, do not use the "All user databases" radio button. Instead, enumerate the live databases explicitly.

  1. In SSMS, expand Management → Maintenance Plans and choose New Maintenance Plan.
  2. Add a Back Up Database Task. In the dialog, select Specific databases and tick only the live WinCC_CC_... and CC_ProcessValueArchive_... databases identified in the previous section. Leave tempdb and any orphan databases unchecked.
  3. Choose the backup type. For a CAS archive, prefer Full weekly plus Differential daily; use Transaction Log only if the recovery model is set to FULL (verify with SELECT recovery_model_desc FROM sys.databases WHERE name = '<DB>').
  4. Specify the backup destination as a stable UNC path on a backup server; never on the same physical disk as the SQL data files.
  5. Set a retention policy (e.g. Backup set will expire after 14 days) and a verification step (Check backup integrity) - this corresponds to the CHECKSUM option in Microsoft's SQL Server backup documentation.
  6. Schedule the plan. The sqlmaint.exe command line generated by the wizard is logged in the Maintenance Plan history; export it for documentation.

Compensation for PCS 7 Project Changes

Whenever a PCS 7 project is re-compiled or downloaded to the CAS, the operator must re-audit the SQL instance before the next scheduled Maintenance Plan run. Use the following checklist:

Project change Expected SQL impact Required action
Tag count increase / archive segment added Possible new archive segment table in existing DB Re-verify database list, no plan change needed
New process picture / new AS assigned Occasionally a new WinCC_* database appears Update Maintenance Plan selection set
Project re-named (ES rename) New WinCC_*_<new_name> database; old one stays Add new DB to plan, detach/drop old DB after verifying data
CAS host rename Old and new databases coexist Same as above
OS re-image of CAS Fresh DBs created on first WinCC start; old DBs may persist if data files were retained Audit sys.databases, prune orphans

Removing Orphan Databases

After confirming a database is orphaned (host renames, project no longer references it, last write time older than the live archive cutoff), remove it deliberately rather than allowing it to be backed up indefinitely.

  1. Stop the WinCC Runtime and the WinCC Archive Manager service on the CAS.
  2. In SSMS, take a final BACKUP DATABASE <OrphanDB> TO DISK = '<archive_path>\<OrphanDB>_final.bak' for audit retention.
  3. Run ALTER DATABASE <OrphanDB> SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  4. Run DROP DATABASE <OrphanDB>;
  5. Verify with SELECT name FROM sys.databases;
Do not rely on the Maintenance Plan to "clean up" by failing on an orphan. The plan will surface a fault, the SQL Agent job will record an error, and any subsequent steps in the same plan (including legitimate backups of healthy databases) may not execute.

Reading the Maintenance Plan Log

The plan history file is the canonical source for diagnosis. Locate it via SQL Server Management Studio → Management → Maintenance Plans → <PlanName> → View History. Common entries and their interpretations:

Log entry Meaning Resolution
Database 'X' does not exist Maintenance Plan references a dropped DB Re-edit plan; remove orphan from selection
BACKUP DATABASE permission denied SQL Agent service account lacks privileges Grant db_backupoperator or sysadmin on instance
Operating system error 5 (Access is denied.) Backup path unreachable or ACL incorrect Verify UNC path and write permission of SQL Agent account
BACKUP LOG cannot be performed because database is in SIMPLE recovery Transaction log backup selected against wrong recovery model Switch DB to FULL recovery or remove log-backup step
The volume on device 'X' is out of space Backup destination full Increase volume or move to a different share; implement pruning
Backup set is corrupt (during verify) Disk fault or write interruption Investigate storage; re-run with CHECKSUM

Restore Verification

A backup is only valid if it can be restored. Schedule a periodic restore drill on a non-production host:

  1. Copy the latest .bak file from the CAS backup share to the test host.
  2. Run RESTORE HEADERONLY FROM DISK = '<path>\<file>.bak'; to verify the backup set.
  3. Run RESTORE VERIFYONLY FROM DISK = '<path>\<file>.bak'; to validate the backup stream without restoring data.
  4. Restore the database under a temporary name using RESTORE DATABASE <TestDB> FROM DISK = '<path>\<file>.bak' WITH MOVE ..., RECOVERY;
  5. Open WinCC Explorer pointed at the restored DB and confirm tag logging and alarm logging queries return valid data.

The verification steps mirror the recommendations in Microsoft's Back up and restore of SQL Server databases reference, in particular the Media errors and Verify backups sections.

Capacity and Retention Sizing

The CAS database grows roughly with the product of (number of archived tags) × (archive cycle) × (retention). Use a representative calculation:

  • Each tag value at a 1-second cycle occupies approximately 16 bytes raw in the compressed archive segment.
  • Daily volume per tag ≈ 16 × 86,400 ≈ 1.4 MB (before compression). WinCC compression typically achieves 5×–10×.
  • Example: 5,000 tags, 7-day online retention, 365-day archive retention on the CAS → approximately 4–7 GB compressed.
  • Plan full backups at 2× this size for breathing room.
Always provide at least 30% free space on the volume hosting SQL data files and 50% free space on the backup share volume. Transaction log growth during heavy archive ingest is a common cause of failed backups.

Troubleshooting Matrix

Symptom Likely cause Corrective action
Maintenance plan succeeds sometimes, fails other times Race with WinCC archive segment switch Schedule plan outside archive segment switch window (e.g. 02:00 / 14:00)
Backup fails immediately after PCS 7 download New archive DB created; old DB dropped Refresh selection list in plan
Backup hangs for hours VSS snapshot stalled or AV scan on backup file Add exclusions for .bak extension in AV
Backup succeeds but restore reports corruption Network path dropped mid-write Use local staging + copy; enable CHECKSUM
Backup file 0 bytes Disk full or path inaccessible at run time Monitor free space; validate UNC before scheduling
Cannot delete orphan database WinCC service holds connection Stop WinCC Archive Manager + WinCC Runtime, then drop

Operational Recommendations

  • Document the sqlmaint.exe command line of every Maintenance Plan in a controlled location (e.g. the project administration folder). Operators must be able to reproduce the plan after a server rebuild.
  • After every PCS 7 download, re-run the database inventory query in Identifying Required vs. Orphaned Databases.
  • Treat the SQL Agent service account as a privileged identity. Backups of a CAS typically contain years of process data; protect the share with ACLs that allow only the SQL Agent service account, administrators, and the restore drill operator.
  • Maintain a 3-2-1 backup policy: at least 3 copies, on 2 different media, with 1 off-site.
  • When migrating the CAS to new hardware, use BACKUP ... WITH COMPRESSION, CHECKSUM to produce a single, verifiable, transferable file rather than detaching and copying raw MDF/LDF files.

FAQ

Should I back up all databases on the WinCC Central Archive Server?

No. Always select specific databases in the Maintenance Plan, excluding tempdb and any orphaned WinCC_* databases from prior host renames or OS images. Selecting "All user databases" is the leading cause of intermittent plan failures.

Why does a Maintenance Plan fail after renaming the CAS computer?

WinCC embeds the host name in the database name. Renaming the host makes WinCC create a new database while the old one remains on the SQL instance; if the plan references the old name, the backup step fails when that database is dropped. Remove the orphan or update the plan to reference the new name.

Do I need to reconfigure the SQL Maintenance Plan after every PCS 7 compilation?

Not necessarily for every compilation. Run the inventory query SELECT name, create_date FROM sys.databases WHERE name LIKE 'WinCC%' after each download and add any newly created archive databases to the plan; remove dropped ones. Compilation-only changes usually reuse the existing database.

How can I verify a CAS backup without disrupting production?

Use RESTORE VERIFYONLY FROM DISK = '<path>\<file>.bak' on a periodic schedule and perform a full restore drill to a test host at least quarterly, as recommended in Microsoft's Back up and restore of SQL Server databases reference.

What is the difference between backing up the MDF/LDF files versus using a Maintenance Plan?

Maintenance Plan backups use SQL Server's native backup stream, capture transaction-consistent state, support compression and CHECKSUM, and can be restored with RESTORE DATABASE. Detaching and copying files bypasses SQL Server and produces inconsistent databases when WinCC is actively writing to them.

Back to blog