# Is it possible to export Schedule (shifts) configuration? or how to copy to another gateway?

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [September 19, 2023, 6:39pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362 "2023-09-19T18:39:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Calderon](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Daniel\_Calderon](https://forum.inductiveautomation.com/u/Daniel_Calderon)\
**Post date:** [September 19, 2023, 6:39pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362/1 "2023-09-19T18:39:08Z")

</div>

Hi

In my development environment I created a pretty complex set of shift schedules for the app. Now I need to have them in the production gateway server. But it looks like the only way is to backup the gateway configuration and restore in production (which is not an option due to different sources names...) or do it again manually.

is there a way to grab the schedules from a database or export them somehow so they don't need to be created manually again? Thanks!

---

<div class="post-metadata">

**Author:** ![schenk](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schenk](https://forum.inductiveautomation.com/u/schenk)\
**Post date:** [September 24, 2023, 7:49pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362/2 "2023-09-24T19:49:36Z")

</div>

I can think of a couple ways to do this

1. Configure a gateway connection between them and use a gateway message handler to return the schedules and create them

2. Write the schedule objects to files from the test gateway and import them on the production gateway

---

<div class="post-metadata">

**Author:** ![Daniel\_Calderon](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Daniel\_Calderon](https://forum.inductiveautomation.com/u/Daniel_Calderon)\
**Post date:** [September 25, 2023, 1:31pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362/3 "2023-09-25T13:31:51Z")

</div>

Thanks a lot Jeremy. Option 2 is the one I think I will try. Had not thought about looking for a system function that could deal with schedules. Great information!

---

<div class="post-metadata">

**Author:** ![aykchoe](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@aykchoe](https://forum.inductiveautomation.com/u/aykchoe)\
**Post date:** [October 5, 2023, 10:45pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362/4 "2023-10-05T22:45:58Z")

</div>

I just tried this and I got a couple errors I wanted to share how I fixed them.

I had to move fos.close() below oos.writeObject(schedule) in the export script and I had to move fis.close() below schedule = ois.readObject()

**Export**

```auto
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
	filePath = path + schedule.name
	
	fos = FileOutputStream(filePath)

	oos = ObjectOutputStream(fos)
	oos.writeObject(schedule)
    fos.close()
	oos.close()

```

**Import**

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![schenk](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schenk](https://forum.inductiveautomation.com/u/schenk)\
**Post date:** [October 5, 2023, 11:37pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-export-schedule-shifts-configuration-or-how-to-copy-to-another-gateway/79362/5 "2023-10-05T23:37:43Z")

</div>

Yeah, I should have tested that before posting it. The ObjectInput/OutputStream instances need to have the FileInput/OutputStream instances available to create the files/schedule objects 🤦‍♂️
