# Creating Gateway Backup through Perspective User Interface on a button event

**URL:** <https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [December 15, 2022, 9:56am UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660 "2022-12-15T09:56:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Fahad\_M\_A](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Mohamed\_Fahad\_M\_A](https://forum.inductiveautomation.com/u/Mohamed_Fahad_M_A)\
**Post date:** [December 15, 2022, 9:56am UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660/1 "2022-12-15T09:56:31Z")

</div>

I tried to create a backup of the gateway from the Perspective User Interface when user clicks a button by using the system.util.execute function and passing the gateway backup creation command as the parameter but unfortunately it isn't working. Could someone help out with the logic which can be utilized for this purpose? Much appreciated.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 15, 2022, 4:07pm UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660/2 "2022-12-15T16:07:59Z")

</div>

Could you supply the code you're using so that we could see what might be incorrect?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 16, 2022, 12:09am UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660/3 "2022-12-16T00:09:19Z")

</div>

This works, you just need to make sure that your Ignition service is running under an admin account.

```auto
cmd = ['cmd', '/c', r'c:\program files\inductive automation\ignition\gwcmd.bat', '-b', r'c:\temp\bob3.gwbk']
system.util.execute(cmd)

```

Also, this will be run _on the gateway_, not on the local client, if run in Perspective, hence the file will appear on the gateway filesystem, not your local filesystem.

If you want to also be able to download it, you can do something like this below. Not sure if there's a better way that doesn't use sleep....?

```auto
fn = r'c:\temp\bob.gwbk'
cmd = ['cmd', '/c', r'c:\program files\inductive automation\ignition\gwcmd.bat', '-b', fn]
r = system.util.execute(cmd)
import time
t = 0
checkTime = 5 # seconds
timeout = 60 # seconds
while t < timeout and not system.file.fileExists(fn):
	time.sleep(checkTime)
	t += checkTime

if system.file.fileExists(fn):
	data = system.file.readFileAsBytes(fn)
	system.perspective.download(fn.split('\\')[-1], data)
else:
	system.perspective.print('Timed out waiting for gwbk.')

```

---

<div class="post-metadata">

**Author:** ![Mohamed\_Fahad\_M\_A](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Mohamed\_Fahad\_M\_A](https://forum.inductiveautomation.com/u/Mohamed_Fahad_M_A)\
**Post date:** [December 16, 2022, 2:25pm UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660/4 "2022-12-16T14:25:19Z")

</div>

Hey Nick, thank you so much for this! It's working fine now. Really appreciate it!

---

<div class="post-metadata">

**Author:** ![Mohamed\_Fahad\_M\_A](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Mohamed\_Fahad\_M\_A](https://forum.inductiveautomation.com/u/Mohamed_Fahad_M_A)\
**Post date:** [December 16, 2022, 2:29pm UTC](https://forum.inductiveautomation.com/t/creating-gateway-backup-through-perspective-user-interface-on-a-button-event/67660/5 "2022-12-16T14:29:46Z")

</div>

Hey there, I just found the solution for it shared by Nick in this thread. It's working fine now. Thanks for the reply! Really appreciate it.
