Backup and restore (#12)

* Create backup_and_restore.md

* Update mkdocs.yml

* Update backup_and_restore.md

* Update backup_and_restore.md

* Update backup_and_restore.md

* Update backup_and_restore.md

---------

Co-authored-by: Jiaqiang Xu <xjqkilling@gmail.com>
This commit is contained in:
Kaniu 2025-01-20 15:38:49 +08:00 committed by GitHub
parent 97012543d2
commit 9d7f5e2702
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,65 @@
## Overview
There are generally two parts of data to backup
- SeaSearch index metadata
- SeaSearch index document data
The index metadata is saved in a local BoltDB file by default. The document data for the indexes is saved either to local storage or object storage.
## Backup
For different backend storage types, there are some differences in the data that needs to be backed up.
There are two backup strategies, depending on the configured storage backend:
- If you use local storage, you need to backup both index metadata and document data
- If you use object storage, you only need to backup index metadata. Whether and how the document data needs backup depends on your object storage setup.
We assume your `SS_DATA_PATH` is `/opt/seasearch/` and you want to backup to `/backup` directory.
### Backup strategy for local storage
The data files are all stored in the directory specified by `SS_DATA_PATH` environment variable, so just back up the whole directory.
You can directly copy the whole directory to the backup destination, or you can use rsync to do incremental backup.
To directly copy the whole data directory:
```
cp -R /opt/seasearch /backup/data/seasearch-`date +"%Y-%m-%d-%H-%M-%S"`
```
This produces a separate copy of the data directory each time. You can delete older backup copies after a new one is completed.
If you have a lot of data, copying the whole data directory would take long. You can use rsync to do incremental backup.
```
rsync -az /opt/seasearch /backup/data/
```
This command backup the data directory to `/backup/data/seasearch`.
### Backup strategy for object storage
When SeaSearch is deployed with object storage backend, you only need to back up the metadata file.
To directly copy the metadata file:
```
cp /opt/seasearch/_metadata.bolt /backup/data/seasearch-metadata.bolt.`date +"%Y-%m-%d-%H-%M-%S"`
```
This produces a separate copy of the data directory each time. You can delete older backup copies after a new one is completed.
## Restore
Now suppose your primary SeaSearch server has failed, and you are switching to a new machine.
Assume that the deployment location of SeaSearch on the new machine is also `/opt/seasearch`, and the backup files are located at `/backup/data/seasearch-2025-01-18-14-35-45`.
### Restore strategy for local storage
You only need to copy the backup data files to the new machine:
```
cp -R /backup/data/seasearch-2025-01-18-14-35-45/ /opt/seasearch
```
### Restore strategy for object storage
Simply copy the backup file to `/opt/seasearch/` and rename it to `_metadata.bolt`:
```
cp /backup/data/seasearch-metadata.bolt.2025-01-18-14-35-45 /opt/seaserch/_metadata.bolt
```

View file

@ -58,6 +58,7 @@ nav:
- Deploy SeaSearch: usage/deploy.md
- Use and access SeaSearch APIs: usage/use_and_access_seasearch_apis.md
- Https: usage/https.md
- Backup and Restore: usage/backup_and_restore.md
- Configuration: config/README.md
- SeaSearch API:
- Overview: api/overview.md