---
title: "Shift Export/Import"
id: "shift-export-import"
project: "Knowledge Base"
url: "https://docs.sepasoft.com/articles/knowledge-base/shift-export-import"
updated: 2026-09-28T19:26:20Z
---

# Shift Export/Import

## How to Export and Import Ignition MES Schedules Between Gateways

### Prerequisites: Preparing Your Gateways for Migration

Completing these prerequisite steps is essential to prevent file system errors and data conflicts during the migration process. Careful preparation on both the source and target gateways lays the foundation for a successful transfer.

#### On the Source Gateway: Sanitize Shift Names

Before running the export script, you must review all schedules within the Ignition Shift Manager on your source gateway. Any shift times that contain a colon (`:`) must be manually updated to use a hyphen (`-`) instead.

**Example:** A shift time of `06:00-06:55` must be updated to `06-00-06-55`.

This manual update is a critical data governance step. While the export script includes a function to replace colons when creating filenames, modifying the schedule name at the source ensures that the data is consistent within the MES database itself. Relying solely on the script's file-level replacement can lead to mismatches between the schedule's name on the gateway and its corresponding backup filename.

![](/resources/Storage/knowledge-base/new-topic-1/kb2.png)

![](/resources/Storage/knowledge-base/new-topic-1/kb3.png)

#### On the Target Gateway: Remove Default Schedules

### Step 1: Exporting Schedules from the Source Gateway

The export script automates the process of extracting schedule configurations. It programmatically iterates through all available MES schedules on the source gateway, serializes each one into a Java object, and saves it as an individual file in a specified directory on the local file system.

#### Export Script


```python
from java.io import FileOutputStream, ObjectOutputStream

path = 'C:\Temp\Schedules\'

schedules = system.user.getSchedules()

for schedule in schedules:

    # You may need to .replace() any characters in the schedule.name to create a valid file name
    schedule.name = schedule.name.replace(':',"-")

    print schedule.name
    filePath = path + schedule.name

    fos = FileOutputStream(filePath)
    oos = ObjectOutputStream(fos)
    oos.writeObject(schedule)

    fos.close()
    oos.close()
```

#### Executing the Script

Open the **Script Console** in the Ignition Designer connected to your **source gateway**. Copy and paste the entire export script into the console and execute it. The script will create a file for each schedule in the `C:\Temp\Schedules\` directory.

#### Analysis of the Export Script

### Step 2: Importing Schedules to the Target Gateway

The import script effectively reverses the export process. It reads the serialized schedule files from the specified directory, reconstructs the schedule objects, and uses a system function to add each schedule to the target gateway's configuration.

**Import Script**

```python
from java.io import FileInputStream, ObjectInputStream
import os

path = 'C:\Temp\Schedules\'

for f in os.listdir(path):

    fis = FileInputStream(path + f)
    ois = ObjectInputStream(fis)
    schedule = ois.readObject()

    fis.close()
    ois.close()

    system.user.addSchedule(schedule)
```

#### Executing the Script

First, ensure the schedule files exported from the source gateway are present in the directory specified in the script (`C:\\Temp\\Schedules\\`) on the **target gateway** machine. Next, open the **Script Console** in the Ignition Designer connected to your **target gateway**. Copy and paste the import script into the console and execute it.

#### Analysis of the Import Script