Backup iShare Installation & Configuration

Overview

If you are an iShare in the Cloud (ISC) customer then Astun automatically perform daily off-peak backups of the servers; one of the many benefits of being an ISC customer. These backups can be easily restored if an issue should arise.

Here we have include a script to allow you to backup your iShare Installation and Configuration, excluding databases, to a dated folder in your chosen location. Once configured, this may then be run manually or as a Scheduled Task.

See the topic Backing up your Database for details on how to backup your PostgreSQL database(s). You may also wish to Extract Non-System Functions from the iShare Database especially if you have created bespoke Functions.

The Script

REM WARNING: Make sure you change to the directory where iShare backups are stored before running this script
REM          to avoid deleting arbitrary files. Also ensure that the "Start in" directory is set when creating
REM          a Scheduled Task. The "Start in" directory should be the directory where iShare backups are stored
REM          such as D:\Backups\iShare
           
REM Tidy up by deleting files older than x days
REM NOTE: Read the warning above before removing the REM on the line below in order to enable deleting old files
REM PowerShell -NoProfile -ExecutionPolicy Bypass -Command "dir |? {$_.CreationTime -lt (get-date).AddDays(-8)} | del -r"

REM Get the current time, based on http://serverfault.com/a/227375
SET TIMESTAMP=
FOR /F "skip=1 delims=" %%F IN ('wmic os get LocalDateTime') DO IF NOT DEFINED TIMESTAMP SET TIMESTAMP=%%F

MKDIR "%TIMESTAMP:~0,14%"
CD "%TIMESTAMP:~0,14%"

REM iShare Maps

MKDIR .\Astun\iShare\5.4\
XCOPY D:\Astun\iShare\5.4\Paths.xml .\Astun\iShare\5.4\
XCOPY D:\Astun\iShare\5.4\Settings.xml .\Astun\iShare\5.4\

MKDIR .\Astun\iShare\5.4\Studio\config
XCOPY D:\Astun\iShare\5.4\Studio\config\* .\Astun\iShare\5.4\Studio\config\

MKDIR .\Astun\iShare\5.4\WebApps\Web
XCOPY D:\Astun\iShare\5.4\WebApps\Web\mycentralbeds* .\Astun\iShare\5.4\WebApps\Web\
XCOPY D:\Astun\iShare\5.4\WebApps\Web\Web.config .\Astun\iShare\5.4\WebApps\Web\

MKDIR .\Astun\iShare\5.4\WebApps\Web\custom
XCOPY /E D:\Astun\iShare\5.4\WebApps\Web\custom\* .\Astun\iShare\5.4\WebApps\Web\custom\

MKDIR .\Astun\iShare\5.4\WebApps\WebService
XCOPY /E D:\Astun\iShare\5.4\WebApps\WebService\web.config .\Astun\iShare\5.4\WebApps\WebService\

MKDIR .\Astun\iShare\5.4\WebApps\WebService\config
XCOPY /E D:\Astun\iShare\5.4\WebApps\WebService\config\* .\Astun\iShare\5.4\WebApps\WebService\config\

REM iShare GIS

MKDIR .\Astun\iShareGIS\5.4\
XCOPY D:\Astun\iShareGIS\5.4\Paths.xml .\Astun\iShareGIS\5.4\
XCOPY D:\Astun\iShareGIS\5.4\Settings.xml .\Astun\iShareGIS\5.4\

MKDIR .\Astun\iShareGIS\5.4\Studio\config
XCOPY D:\Astun\iShareGIS\5.4\Studio\config\* .\Astun\iShareGIS\5.4\Studio\config\

MKDIR .\Astun\iShareGIS\5.4\WebApps\Web
XCOPY D:\Astun\iShareGIS\5.4\WebApps\Web\cbcgis* .\Astun\iShareGIS\5.4\WebApps\Web\
XCOPY D:\Astun\iShareGIS\5.4\WebApps\Web\web.config .\Astun\iShareGIS\5.4\WebApps\Web\

MKDIR .\Astun\iShareGIS\5.4\WebApps\Web\custom
XCOPY /E D:\Astun\iShareGIS\5.4\WebApps\Web\custom\* .\Astun\iShareGIS\5.4\WebApps\Web\custom\

MKDIR .\Astun\iShareGIS\5.4\WebApps\Web\print
XCOPY /E D:\Astun\iShareGIS\5.4\WebApps\Web\print\* .\Astun\iShareGIS\5.4\WebApps\Web\print\

MKDIR .\Astun\iShareGIS\5.4\WebApps\WebService
XCOPY /E D:\Astun\iShareGIS\5.4\WebApps\WebService\web.config .\Astun\iShareGIS\5.4\WebApps\WebService\

MKDIR .\Astun\iShareGIS\5.4\WebApps\WebService\config
XCOPY /E D:\Astun\iShareGIS\5.4\WebApps\WebService\config\* .\Astun\iShareGIS\5.4\WebApps\WebService\config\

MKDIR .\Astun\iShareGIS\5.4\WebApps\WebService\xml
XCOPY /E D:\Astun\iShareGIS\5.4\WebApps\WebService\xml\* .\Astun\iShareGIS\5.4\WebApps\WebService\xml\

REM Common

MKDIR .\iShareData\
XCOPY /E D:\iShareData\* .\iShareData\
REM XCOPY /E /exclude:\path\to\excludelist.txt D:\iShareData\* .\iShareData\

CD ..

How to Implement

  • Save the above script as a batch file (.bat) e.g. isharebackup.bat, in a folder on the drive where you would like your backups to be stored, for example E:\backups\isharebackup.bat
  • Review the script to ensure the XCOPY lines are appropriate for your installation. For example, check the drive letters and version numbers. 
  • Check your Tilecache Considerations (see below) and alter the script accordingly.
  • Save your changes.

Tilecache considerations

Your tilecache directory may be 10s of gigabytes in size. If your tilecache is stored in a sub-directory of iShareData, then this script will also back that up. 

Consider whether you need to do this, and whether you have the space to do so in the backup location. 

If you do not wish to back up the tilecache, then:

  • Create a text file called excludelist.txt and add files of type png to it e.g.

    *.png\ 
    *.log\
  • Then comment out the third line from the bottom of this script (i.e. add REM to the start) e.g.

    REM XCOPY /E D:\iShareData\* .\iShareData\
  • Un-comment the second to last line (i.e. remove REM from the start) e.g.

    XCOPY /E /exclude:\path\to\excludelist.txt D:\iShareData\* .\iShareData\

Running the Script

Manually

  • Open a command prompt.
  • Change to the folder that will contain your backups.

    If you have enabled deleting "old" backups then it is especially important that you change to an empty directory to avoid accidentally deleting files.

  • Run the .bat file from a command prompt, as a user that has access to all the file locations listed. If it is set up correctly it will create a folder with the date and time of the run as a subdirectory of the location where the batch file is run from. This will contain a copy of the entire iShare Installation and Configuration.

As a Scheduled Task

Ensure that the "Start in" directory is set when creating a Scheduled Task. The "Start in" directory should be the directory where iShare backups are stored such as D:\Backups\iShare.