Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Markdown
# Backup and Restore

- [Introduction](#introduction)
- [SQL Server](#sql-server)
- [Backup Procedure](#backup-procedure)
- [Restore Procedure](#restore-procedure)

## Introduction

To ensure that server failures or data corruption do not result in a permanent loss of the ability to do searches, it is recommended to do backups every now and then.

Backups are done by running the backup script described in the next section. If one is using an external Microsoft SQL server as the database, then that one has to be backup in addition.

A full list of what is being backed up can be obtained by running Get-Help .\backup-data.ps1.
Whereas the backup procedure is done by a script, the restore procedure is manual and described int the last section of this documentation.

## SQL Server

If Saga is configured with an external SQL Server database, then database backups are the responsibility of the administrators of that database.

## Backup Procedure

To back up Saga, run the `D:\Program Files\ayfie\saga\scripts\backup-data.ps1` script (assumes recommended installation path). The script will create snapshots for MongoDB and Chat collection in Solr, stop Saga, back up all required files to `D:\Program Files\ayfie\saga\backup\data\<yyyyMMddHHmmss>` and then start Saga again. The backup directory should be moved to another server.

## Restore Procedure

This is how to restore Saga using the backed up data:

 - Stop Saga.
 - Remove everything under `D:\Program Files\ayfie\saga` (assumes recommended install directory path)
 - Install Saga from scratch by following the [Ayfie Locator Installation Guide](https://ayfie-dev.atlassian.net/wiki/spaces/SAGA/pages/2400714758/Ayfie+Locator+Installation+Guide).
 - During the installation, answer _Y_ to the EULA question and directly click _== Exit ==_ when the menu comes up.
 - Once Saga is fully up and running, stop it again.
 - Manually replace the items that were created during backup procedure.
 - Start Saga.
 - Once Saga is fully up and running, reindex all data with this command:
`docker exec ayfie-locator PowerShell C:\Locator\Tools\Via.Repository.exe REINDEX /all`
 - Solr's Chat collection is restored by doing following steps:
    - Check if `Chat` collection in Solr was created by visting http://localhost/solr and clicking `Collections` on the left side menu.
      - If `Chat` collection doesn't exist, it has to be created by making `GET` request to `http://localhost/solr/admin/collections?action=CREATE&name=Chat&collection.configName=Chat&numShards=1&replicationFactor=1`. This step can be done by simply copying the URL and pasting into web browser or by running command below in powershell:\
      `Invoke-WebRequest "http://localhost/solr/admin/collections?action=CREATE&name=Chat&collection.configName=Chat&numShards=1&replicationFactor=1"`
      - If `Chat` collection exists the move to next step.
    - `Chat` collection's data is restored by sending `GET` request to  `http://localhost/solr/Chat/replication?command=restore`. This can be done by pasting to URL to web brower or by running the command below in powershell: \
     `Invoke-WebRequest "http://localhost/solr/Chat/replication?command=restore"`. 
     This request will restore Chat collection using latest snapshot located in `D:\Program Files\ayfie\saga\data\solr\Chat_shard1_replica_n1\data\`
 - MongoDB is restored by calling the command below in Powershell: \
 `docker exec ayfie-chat-db C:\mongodb-tools\bin\mongorestore.exe --uri mongodb://localhost:27017`
 - Open the Management Console to see the list of all connectors that were in use:
 `.\start-management-console.ps1`
 - Install all the listed connectors as described in section _Installing Connectors_ of the [Ayfie Locator Installation Guide](https://ayfie-dev.atlassian.net/wiki/spaces/SAGA/pages/2400714758/Ayfie+Locator+Installation+Guide)