Layers from GIS Cloud maps can be periodically exported locally on the computer.
There are a few steps that you need to follow to set everything up.
The first step is to download and unzip the script for an automatic backup of your data.
Table of Contents
Set backup for Windows
Generate a new API key
API key is unique for each user and is used to identify the user and to check if the user has export permission on the layer.
- Open My Account in Map Editor.
- Open API Access tab.
- Type in a new name for the key in New API key description and click Add key.
- Copy the created key as you will need it later for the setup!
Find layer ID
While you are still in Map Editor, the next step is to copy the layer ID for which you want to set up backup. Note that you can backup only layers for which you have the export permission.
- Open the map in which the layer is added.
- Go to Layer Properties (Layers tab – Edit layer).
- Under General tab click More info button.
- Copy the layer ID as you will need it later in the setup!
Create a new task in Task Scheduler for Windows
The next step is to create a task for a daily backup. In this example, we will use the Task Scheduler for Windows. Task Scheduler is located in Control Panel – System and Security – Administrative Tools – Task Scheduler.
1. Define the name of the backup task in the General tab.
2. Create the trigger for initialization of the backup process.
3. Create an action for the trigger.
To create an action we will need an API key, layer ID, path to the script and path to the location in which data will be stored (more details can be found in “readme.txt” file)
4. In the Program/script enter “wscript”
5. In the Add arguments box copy the path to the script, API key, layer ID and path to the location in which data will be stored:
e.g. “C:\Users\tihana\Desktop\GIS-Cloud-data-backup\GIS Cloud data backup\gc-export-shape.wsf” /layer:2224304 /apikey:3c01edddff7c5b913bcec1204c3dfd98 /dest:C:\Users\tihana\Desktop\streetlights_backup
6. Default export format is ESRI Shapefile, but you can add an argument to export to a different format: /format:<export format>
Possible <export format> values are:
- “esri shapefile”
- “mapinfo file”
e.g. “C:\Users\tihana\Desktop\GIS-Cloud-data-backup\GIS Cloud data backup\gc-export-shape.wsf” /layer:2224304 /apikey:3c01edddff7c5b913bcec1204c3dfd98 /dest:C:\Users\tihana\Desktop\streetlights_backup /format:”dxf”
- The path to the exported layer (/dest:C:\Users…) shouldn’t have any spaces as it causes the error when executing the script.
- Check if you copied all the quotes, all necessary spaces.
These steps will ensure that your backup is done by the defined parameters.
Test the script by clicking Run in Task Scheduler. In log.txt you can if the layer is successfully downloaded. The layer should be stored in the defined folder.
Note: It is necessary that the computer is turned on at the time of the backup.
Set backup for Linux
To back up once a week on Sunday, set up a crontab job like this:
0 2 * * 7 /usr/bin/bash <path to gc-export.sh> -l <layer id> -k <API key> -d <destination directory> > <path to log file> 2>&1
Replace /usr/bin/bash with the location of your bash executable. It can be in a different location depending on your OS or setup. The location of the executable can usually be checked with command:
The default export format is ESRI Shapefile, but you can add an argument to export to a different format:
-f <export format>
Possible <export format > values are:
Don’t forget the quotes! e.g. -f “esri shapefile”
Of course, the user running the script must have permissions to write to the destination directory.