Siemens S7-1200 TIA Portal: Online Backup and Block Recovery

David Krause15 min read
S7-1200SiemensTutorial / How-to
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

1. Problem Overview: Outdated Offline Project vs. Live CPU State

When the offline STEP 7 project on the engineering station is older than the live program in the S7-1200 CPU, the standard workflows ("drag block from online to offline", "Save As" of the online tree, "Archive" the online project) all produce an offline copy that looks current but is missing some program objects. The most common missing objects are Function (FC) and Function Block (FB) containers, instance Data Blocks (DB), system Data Blocks (SDB), PLC tags tables, and PLC data type definitions (UDTs) that were added after the last save on the engineering station.

The symptoms this article addresses are:

  • FC/FB is present in the CPU online view but disappears the moment the project is closed or the offline cache is refreshed.
  • The online "Save As" or "Archive" command produces a project that opens without warnings but no longer contains the missing blocks.
  • The block timestamp (Code generation / Last modified) shown online does not match the timestamp stored in the offline block container.
Important: For an S7-1200 (firmware V4.0 through V4.7) the live program is always the authoritative source. The TIA Portal offline project is a view, not a synchronized copy. The only safe way to recover a fully consistent program is to pull the project state out of the CPU using one of the three procedures documented in §4 to §6.

2. Why the Three Common Approaches Fail

Before the recommended procedure is presented, the failure modes of the three approaches engineers usually try first are documented. Knowing why they fail prevents the same operations from being repeated on a fresh project file.

2.1 Copy-Paste of Single FBs from the Online Tree

Selecting a Function Block in the project tree's "Online" view and copying it to the offline project copies only that FB, plus the system data block (SDB) implicitly used at compile time. Any associated FC, instance DB, or PLC tag that the FB depends on is not copied. After a save, the compiler raises a "block is inconsistent or missing" warning and the missing FC remains absent. This procedure is intended for targeted patch diffs, not for full program recovery.

2.2 Save As / Save Project As on the Online View

"Project > Save As" in TIA Portal creates a new TIA project file (.ap1x) that contains the current in-memory state of the offline project. It does not read from the CPU. The online view is shown for reference only; it is not written to disk by Save As. The block list therefore reflects the same offline tree that was already open, with the same gaps.

2.3 Archive the Online Project

"Project > Archive" produces a .zap1x compressed archive of the current offline project. The behaviour is identical to Save As in terms of which blocks are stored. The archive is internally consistent, but it is consistent with the wrong source: the offline tree, not the CPU.

3. Prerequisites Before Touching the Live CPU

Performing an online backup of a running S7-1200 is a non-destructive read operation, but the following prerequisites minimise the risk of an offline/online mismatch being introduced into the production line:

  1. Identify the CPU and firmware. Read the order number (for example 6ES7214-1AG40-0XB0 for a CPU 1214C DC/DC/DC, 6ES7215-1AG40-0XB0 for a CPU 1215C, or 6ES7212-1AE40-0XB0 for a CPU 1212C) and the firmware version from the operator panel or from the online diagnostic buffer. Confirm TIA Portal version compatibility (TIA V15.1 supports S7-1200 firmware V4.0-V4.4; TIA V16 supports up to V4.5; TIA V17/V18/V19 support V4.6/V4.7). A TIA Portal version older than the firmware will refuse the upload.
  2. Identify the connection path. S7-1200 backup can be performed over PROFINET, Ethernet, or via the Web server. Direct MPI/DP is not supported on the S7-1200. Make sure the engineering station has a routable IP address to the CPU's PROFINET interface and that no firewall blocks TCP port 102 (ISO-on-TCP, used for the S7 communication).
  3. Confirm the protection level of the CPU. If "Full access (no protection)" is not set, the PLC password must be supplied during the online backup. For know-how-protected blocks the password of the block itself (not the CPU password) is required; without it the block is uploaded as a stub with no code body.
  4. Ensure the CPU is in RUN or STOP. S7-1200 supports online read access in both states. For a consistent upload of all blocks including the SDB, STOP is preferred; the procedure is non-disruptive because uploading only reads flash.
  5. Take a backup of the existing offline project anyway. Even though the offline project is known to be out of date, it contains operator comments, HMI tag mappings, and library references that are not stored on the CPU. A .zap1x archive of the existing offline project must be kept before any overwrite.

4. Procedure A: Upload from Device (Recommended Primary Method)

This is the procedure the Siemens FAQ and TIA Portal Help both call out as the canonical way to bring the CPU's program into the engineering station as a fully consistent TIA project.

4.1 Step-by-Step

  1. In TIA Portal, create a new empty project: Project > New.... Name the project using the plant designation plus the date stamp, for example Line3_S7-1200_Backup_2024-05-14.ap1x.
  2. In the project tree, right-click the project node and select Online > Device detection to confirm reachability. TIA Portal will list the detected PROFINET nodes and their MAC addresses; locate the S7-1200 by its MAC (printed on the front of the CPU) or by its IP address.
  3. Right-click the project node and select Online > Upload from device (Software including HMI and Web data). The corresponding menu entry appears in TIA V15.1 onward and in TIA V17/V18/V19 as Online > Upload from device.
  4. In the "Upload from device" dialog, choose the target PG/PC interface (for example Intel(R) Ethernet Connection I219-V) and the destination subnets (typically the directly-attached PROFINET subnet). Click Start search.
  5. After search completes, select the S7-1200 CPU entry (the icon is the orange "PLC" triangle) and click Upload. The progress dialog shows the blocks being read. For a typical S7-1214C with 40 FBs/FCs the upload completes in 30-90 seconds.
  6. When the upload is finished, expand Program blocks in the project tree and verify that all FC, FB, OB, DB, SDB, and SFB/SFC blocks are present. Cross-check the count against the count shown in the online view before the upload was started.
Note: The uploaded project contains the program blocks and the hardware configuration stored in the CPU. It does not contain the PLC tag tables, the watch tables, the HMI screens, or the program documentation. These must be copied back from the prior offline project after step 4.1.6. The matching can be performed by right-clicking each block in the offline project and selecting Compare > Online/Offline; TIA Portal offers a "Detailed comparison" view that highlights missing blocks and timestamp mismatches.

4.2 Handling Know-How-Protected Blocks

If a block has been compiled with know-how protection (right-click block > Properties > Protection), the upload returns the block with the protection intact, but the code body is not readable. The block executes identically to the live CPU, so it can be archived as-is, but it cannot be edited or re-compiled. To preserve the source code, the project that originally contained the unencrypted source must be kept.

5. Procedure B: TIA Portal "Create Online Backup" Function

Starting with TIA Portal V15.1, the S7-1200 system manual describes a project-embedded backup feature that the S7-1200 CPU can store internally. Per the SIMATIC S7-1200 Programmable Controller System Manual (entry ID 109759862), the steps are:

  1. Connect TIA Portal to the S7-1200 and select the CPU in the project tree.
  2. Open the "Online & Diagnostics" view and navigate to the "Backup PLC" section.
  3. Click Create online backup. TIA Portal reads the full program and configuration from the CPU and writes a self-contained .s7pbkp file to the engineering station.
  4. Save the .s7pbkp file in a versioned directory, for example \\plant-archive\Line3\S7-1200\2024-05-14\Line3_CPU1214.s7pbkp.

The .s7pbkp file is restored with the matching Restore from online backup button in the same dialog. The file is hardware-bound: a .s7pbkp taken from a CPU 1214C with order number 6ES7214-1AG40-0XB0 can only be restored to an identically ordered CPU (or one with a higher article number within the same functional range). This feature is suitable for fast board-swap recovery and not for migrating code between projects.

6. Procedure C: Web Server Backup (No TIA Portal Required)

When the engineering station is not running TIA Portal or when the field engineer needs to take a backup from a phone or tablet, the S7-1200 Web server can be used. The S7-1200 Web server is enabled in the CPU properties under Web server > Activate Web server on this module. Refer to the TIA Portal S7-1200 Manual Collection: Backing up an online CPU for the detailed procedure.

  1. Open a browser and navigate to http://<cpu-ip>/. The default page shows module identification, diagnostic buffer, and tag tables.
  2. Click the Module Information or Backup entry. The exact entry name depends on the S7-1200 firmware version: V4.0 shows "Module Information"; V4.4 and later show a dedicated "Backup" tab.
  3. Select the items to back up: Data logs, Recipes, User-defined Web pages, and Backing up an online CPU files.
  4. Click Download. The browser saves the backup as a .bin or .tar file in the default download folder.
Critical: Per the official documentation, backup files obtained through the Web server cannot be restored using the TIA Portal Restore from online backup function. They are intended for transferring data logs, recipes, and user-defined Web pages between CPU and engineering station. For program code, Procedure A or Procedure B is required.

7. Procedure D: Block-by-Block Recovery (Last-Resort Method)

When the TIA Portal installation on the engineering station is older than the CPU firmware and cannot be upgraded (for example, the line cannot be stopped to install TIA V19), the upload can be performed block by block. This is also the recommended method when only a small number of blocks is missing and a full upload is not desired.

  1. Open the offline project that should receive the missing blocks.
  2. Switch to the online view: in the project tree, click the orange "Online" arrow icon in the toolbar. TIA Portal queries the CPU using the currently configured PG/PC interface.
  3. Right-click the FC (or FB/DB) that is missing in the offline tree and select Upload to PG/PC in the online context menu. TIA Portal copies the block from the CPU to the offline project.
  4. Repeat for each missing block. Use the online "Compare > Online/Offline" view to confirm that all timestamps and CRC signatures now match.

This method does not bring over hardware configuration, PLC tag tables, or watch tables, but it correctly handles a small set of missing FCs. The resulting offline project must be re-compiled before downloading back to the CPU.

8. Verification After the Backup

Whichever procedure is used, perform the following checks before considering the backup complete:

Check Method Pass Criterion
Block count matches Project tree > Program blocks > count visible online vs. offline Counts are identical for OBs, FBs, FCs, DBs, and SDBs
Block timestamps match Right-click Program blocks > Compare online/offline > Detailed comparison No entries with red "Time stamp differs" icon
Block CRCs match Online > Online & diagnostics > Compare All blocks show "Identical" status
Hardware configuration present Project tree > Device configuration CPU, signal modules (SM), signal boards (SB), and any communication modules are listed
PLC tag tables present Project tree > PLC tags > Default tag table and any user tag tables Tables are present and contain all tags
Watch tables present Project tree > Watch and force tables Watch tables from the previous offline project are still present
Library references resolved Libraries pane > right-click library > Show version All library references resolve without a yellow warning triangle
Compile succeeds Project tree > right-click CPU > Compile > Software (rebuild all blocks) Compile finishes with 0 errors

9. Programmatic Verification with the TIA Portal Openness API

For plants with a large number of S7-1200 CPUs, the TIA Portal Openness API (available with STEP 7 Professional and the Openness option) can script the upload. A minimal C# example that uploads the first CPU found on subnet 192.168.0.0/24 is shown below. This is suitable for a scheduled, unattended backup.

// C# / TIA Openness V17 example
using Siemens.Engineering;
using Siemens.Engineering.HW;
using Siemens.Engineering.Online;

var tia = new TiaPortal(TiaPortalMode.WithUserInterface);
var project = tia.Projects.Open(new FileInfo(@"C:\Backups\Line3\Template.ap17"));
var subnet = project.GetService<INet>().Subnets[0];

foreach (var device in subnet.GetDevices())
{
    if (device.DeviceIdentification.TypeName != "S7-1200") continue;

    var cpu = device as IPlcCpu;
    var onlineProvider = cpu.GetService<IOnlineProvider>();
    var configuration = onlineProvider.Configuration;
    var target = configuration.OnlineTarget;

    var uploadResults = target.Upload();
    foreach (var res in uploadResults)
    {
        Console.WriteLine($"Block {res.BlockName} upload state: {res.State}");
    }
}

project.Save();
project.Close();
tia.Dispose();
Compatibility: The IOnlineProvider and OnlineTarget.Upload() calls require TIA Portal V15.1 or later. The Openness DLL Siemens.Engineering.dll must be referenced from the TIA Portal installation directory. The script does not require user interaction after the project is opened, making it suitable for Task Scheduler execution under a service account.

10. Troubleshooting Matrix

Symptom Likely Cause Resolution
"Device not reachable" during upload PG/PC interface not bound to the correct NIC, or CPU is on a different subnet Set PG/PC interface to the NIC connected to the S7-1200 PROFINET network; add a route in TIA Portal under "Online access > Accessible nodes"
"CPU is in a different protection level" CPU protection level is set to "Read access" or higher Switch CPU to "Full access (no protection)" in Properties > Protection, or supply the CPU password in the online dialog
Uploaded block is empty (no code body) Source block was know-how protected Source project with unencrypted block must be retained; the protected block is recovered as a non-editable stub
Upload completes but FBs are missing instance DBs Instance DBs are stored as SDB and were created by the CPU at first run After upload, perform a full STOP/START cycle to let the CPU regenerate instance DBs; or compile the offline project and download only the program blocks (not the hardware configuration)
"Firmware version not supported" TIA Portal is older than the CPU firmware (e.g. TIA V16 cannot read a V4.6 S7-1200) Upgrade TIA Portal to V17, V18, or V19; or upgrade the CPU firmware to a version the installed TIA Portal supports
Online backup (.s7pbkp) is too large to restore Backup includes recipe data, data logs, or user-defined Web pages Use the web server method to retrieve data logs separately; perform a program-only backup via TIA Portal
Block timestamp shows old date after upload CPU real-time clock was set to 2000-01-01 because no battery or NTP was configured Configure the CPU's time-of-day synchronisation (NTP or PG/PC time) and re-upload
"Project is read-only" when trying to save Project file or directory has the read-only flag, or the .ap1x file is on a network share without write permission Copy the .ap1x file to a local writable directory before performing the upload

11. Field-Proven Recommendations

  • Adopt a "single source of truth" policy: only the live CPU is the source of truth. Treat any offline project as a working copy.
  • Schedule an automatic upload using the TIA Openness API (see §9) once per shift, and store the .ap1x files on a file server with retention matching the audit policy of the plant.
  • Maintain a side-by-side folder for the previous offline project. The merge of PLC tag tables, watch tables, and HMI screens is far easier when both the "known-good" offline project and the freshly uploaded one are available.
  • Document the CPU password in the plant's password vault. A CPU with the protection level "Read access" requires the password to be entered at every online session, which can block an upload from an unattended backup script.
  • After every firmware upgrade of the S7-1200, immediately perform Procedure A or Procedure B. The new firmware can change internal SDB layout, and an offline project compiled for the old firmware will not re-import cleanly.
  • For multi-user projects (TIA Portal Multiuser), do not perform the upload from the central server project. Upload into a local working copy first, then merge the hardware configuration and program blocks back into the central project using the multi-user commit procedure.

Why does Save As of the online project still miss FCs that are visible online?

Save As in TIA Portal writes the current offline in-memory project to disk. The online view is a read-only cache; Save As does not refresh the offline tree from the CPU. The blocks that were never loaded into the offline tree are therefore not saved. The correct path is Project > Online > Upload from device, which explicitly reads the live program from the CPU and populates a new project.

Can I back up an S7-1200 over MPI or PROFIBUS?

No. The S7-1200 has no MPI or PROFIBUS DP interface. Online backup, upload from device, and the create-online-backup function all use the PROFINET interface (Ethernet) and the S7 communication protocol on TCP port 102. For PROFIBUS-based S7-300/400 systems the equivalent procedure uses STEP 7 V5.5 with the "Upload to PG" function.

What TIA Portal version do I need to upload from an S7-1200 firmware V4.6 CPU?

TIA Portal V18 or V19 is required. V17 can read a V4.5 CPU but does not support V4.6. TIA V16 supports up to V4.5 only. When the installed TIA Portal is older than the CPU firmware, the CPU is shown in the online accessible nodes with a warning icon and the upload is blocked.

Does the .s7pbkp file work as a long-term archive?

Yes for the program blocks and hardware configuration of the same CPU article number. It does not include PLC tag comments, watch tables, or HMI screens, so it must be paired with a regular TIA Portal .ap1x archive if those are part of the project. The .s7pbkp is hardware-locked; a backup taken from a CPU 1215C (6ES7215-1AG40-0XB0) cannot be restored to a CPU 1214C (6ES7214-1AG40-0XB0).

How do I recover a know-how protected block after the source project is lost?

You cannot. Know-how protection encrypts the code body with a block-specific password. The CPU stores only the encrypted code; there is no backdoor or extraction tool supplied by Siemens. The recommended practice is to keep the original unencrypted project in a controlled archive directory; the encrypted block on the CPU is sufficient for execution but not for source recovery.

Back to blog