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 firstthe stoppingbackup Saga,script thendescribed copyingin the 3next itemssection. listedIf belowone tois anotherusing server,an beforeexternal finallyMicrosoft startingSQL Sagaserver againas (the descriptiondatabase, assumesthen that theone recommendedhas installto directorybe isbackup being used):in addition.

-A Allfull directorieslist under `D:\Program Files\ayfie\saga\data` with the exception of Solr and Zookeeper directories
 - The Docker configuration file `D:\Program Files\ayfie\saga\docker\custom.env`
 - The directory `D:\Program Files\ayfie\saga\volumes`

The items above hold data of various types that is retrieved or produced by Saga during normal operation. This includes various databases of which the most important one is the one holding source data retrieved by the connectors. As the index (Solr and Zookeeper) can become very large and one can relatively quickly reconstruct it from the stored source data, these instructions do not include backing up the index but rather later rebuilding it from the restored dataof 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 3 items describedthat inwere thecreated introductionduring with the backed up databackup 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)