# \[Linux\] How to do a CLI backup/restore of the gateway

**URL:** <https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929>\
**Category:** General Discussion\
**Created:** [January 31, 2014, 3:31pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929 "2014-01-31T15:31:23Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![BSH](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@BSH](https://forum.inductiveautomation.com/u/BSH)\
**Post date:** [January 31, 2014, 3:31pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/1 "2014-01-31T15:31:23Z")

</div>

Hi,  
I’m wondering if it is possible to do a backup of the gateway from the CLI on a Linux OS. Also if this is possible how could I do a restore afterwards?  
If it is in the manuals please point me in the right direction because I have not been able to find it so far.

Thanks,  
Bart

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [January 31, 2014, 3:45pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/2 "2014-01-31T15:45:49Z")

</div>

Yes, it’s possible to do Gateway backups and restorations from the command line. You run a command called gwcmd with the following options:

`gwcmd --backup <path to download .gwbk>
gwcmd --restore <path to .gwbk>
`  
You can also run gwcmd by itself to get all the command like options and info.

---

<div class="post-metadata">

**Author:** ![BSH](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@BSH](https://forum.inductiveautomation.com/u/BSH)\
**Post date:** [January 31, 2014, 3:50pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/3 "2014-01-31T15:50:33Z")

</div>

When I try that it gives me the following output:

`./gwcmd.sh --backup /home/sbart/test.gwbk
Exception in thread "main" java.lang.NoClassDefFoundError: com.inductiveautomation.catapult.control.HeadlessControlUtil
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: com.inductiveautomation.catapult.control.HeadlessControlUtil not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
   at gnu.java.lang.MainThread.run(libgcj.so.7rh)
/local/apollo/package/local_1/Linux-2.6c2.5-x86_64/FCControls_Ignition/FCControls_Ignition-40.0-0/Ignition`

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [January 31, 2014, 5:00pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/4 "2014-01-31T17:00:03Z")

</div>

Which version of Java is this? Currently, we only support Oracle Java and OpenJDK 7 on Linux. Also, I have since learned that the restore feature is coming in 7.7, so only the backup portion is available right now.

---

<div class="post-metadata">

**Author:** ![BSH](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@BSH](https://forum.inductiveautomation.com/u/BSH)\
**Post date:** [February 6, 2014, 4:38pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/5 "2014-02-06T16:38:12Z")

</div>

It’s:

java version “1.7.0\_45”  
Java™ SE Runtime Environment (build 1.7.0\_45-b18)  
Java HotSpot™ 64-Bit Server VM (build 24.45-b08, mixed mode)

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [February 6, 2014, 9:28pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/6 "2014-02-06T21:28:20Z")

</div>

I would recommend installing Oracle Java 7. Then gwcmd should definitely work. If you know for sure that you have Oracle Java 7, then something else is going on, like the wrong Java is in the system path or something like that.

---

<div class="post-metadata">

**Author:** ![BSH](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@BSH](https://forum.inductiveautomation.com/u/BSH)\
**Post date:** [February 13, 2014, 5:45pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/7 "2014-02-13T17:45:53Z")

</div>

From the gateway screen:

Version 7.6.4 (b2013112117)  
Java Version Oracle Corporation 1.7.0\_51

So it is Oracle Java.

The gateway itself is working properly just the command line backup.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [March 9, 2015, 11:50pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/8 "2015-03-09T23:50:15Z")

</div>

I know this is a really old issue that was reported. There were a number of tickets where it seemed doing gateway backups from the command line was not working correctly. I did find that this issue was resolved for 7.7.3, FWIW

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [May 28, 2015, 2:32pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/9 "2015-05-28T14:32:24Z")

</div>

Hi, I’m also trying to do a backup of the gateway from the CLI on a Linux OS but in my case the error is diferent:

```auto
gwcmd --backup /home/ignition/backups/
Error! Error! Could not move /var/lib/ignition/temp/gatewayBackupTEMP911672483228459577.gwbk to /home/ignition/backups/Ignition-backup-20150528-1533.gwbk
```

As you can see the file has been generated but it has not been possible to move it to another folder. However, if I move the file manually it works. Someone can tell me what could be the problem?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [May 28, 2015, 2:46pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/10 "2015-05-28T14:46:38Z")

</div>

It sounds like the OS is not letting you delete the old file during the move, as the error looks to be coming from the OS. Which Linux OS is this? Also, how are you running gwcmd? Via a script in a cron task?

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [May 28, 2015, 3:04pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/11 "2015-05-28T15:04:47Z")

</div>

The OS is CentOS release 6.4 (Final)

Currently I’m doing test using the console, but the goal is to execute it via script in a cron task.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [May 29, 2015, 11:25am UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/12 "2015-05-29T11:25:31Z")

</div>

This is right from the manual, just not sure if you seen it.

[code]Scheduled Backups  
These 4 properties (enable, backup folder, backup times, and retention count) control the Gateway’s scheduled backup system. This system is capable of automatically making a Gateway backup and storing it to a folder path, which may be a network path. When you enable this system, you must specify a destination folder. This may be a local folder, for example “C:\backups” or “/var/backups” or a network path such as “\fileserver\backups”.

The scheduled backup system works on a schedule that is specified using UNIX crontab syntax. This is a standard format for specifying a basic schedule. The format consists of five space-separated fields, one for minute, hour, day-of-month, month, and day-of-week. The special character \* means “all”. Slashes can be used to indicate that values should be stepped, for example, \*/5 in the minutes field means “every 5 minutes”, or 0:00, 0;05, 0:10, etc. Some examples:  
5 \* \* \* \*  
Once an hour, on the :05 minute. 0:05, 1:05, 2:05, etc.  
\*/15 \* \* \* \*  
Every 15 minutes, on the quarter-hour. 0:15, 0:30, 0:45; 1:00, 1:15, etc.  
30 5 \* \* Mon  
Every Monday at 5:30am

- 6-14 \* \* \*  
Every minute, but only between 6am and 2pm  
\*/5 8-17 \* \* 1-5  
Every 5 minutes between 8am and 5pm but only during the week (1-5). 0=Sunday, 1=Monday, etc.  
0 1 5 \* \*  
Once a month, on the 5th day at 1am  
[/code]

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [June 1, 2015, 10:25am UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/13 "2015-06-01T10:25:02Z")

</div>

Thanks Jim but the problem appears when I run the command on the console:

On the other hand, I tried to execute the command via script in a cron task

but show me a different error:

```auto
/home/ignition/scripts/launch-backup-ignition.sh: line 2: gwcmd: command not found
```

Any hints on what I’m doing wrong? The version of Ignition is 7.6.4

Regards

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [June 1, 2015, 11:15am UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/14 "2015-06-01T11:15:01Z")

</div>

Looking at the first error message I would say it is a permission issue to write to that folder, but it looks like you are “root”.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [June 17, 2015, 3:14pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/15 "2015-06-17T15:14:17Z")

</div>

Just a guess here but generally in a cron script you have to supply a complete path to each executable you want to run. Reason being that the cron task does not create the same env that you as a logged in user has.

eg: gwcmd … should be /home/ignition/bin/gwcmd …

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [June 18, 2015, 7:28am UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/16 "2015-06-18T07:28:39Z")

</div>

Thanks Robert for the input. The second problem has been fixed but not the first. Does anyone know if there is a known issue with the version 7.6.4 related to “gwcmd” command?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 18, 2015, 12:35pm UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/17 "2015-06-18T12:35:16Z")

</div>

What user owns the folder where you are trying to place the backup? If you created that subfolder with root, and the gwcmd is switching to the ignition user (which it must for various operations), then it won’t be able to reach that folder. Also true for your crontab. Consider using “su - ignition” to take the ignition identity before manipulating ignition’s files and folders. Also lets you conveniently access ignition’s own crontab.

---

<div class="post-metadata">

**Author:** ![shv](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shv](https://forum.inductiveautomation.com/u/shv)\
**Post date:** [June 19, 2015, 10:13am UTC](https://forum.inductiveautomation.com/t/linux-how-to-do-a-cli-backup-restore-of-the-gateway/7929/18 "2015-06-19T10:13:19Z")

</div>

ok pturmel, now works. Thanks for the help guys.
