From 9d7f5e27020607e48f390670a20079d21ff87dda Mon Sep 17 00:00:00 2001 From: Kaniu Date: Mon, 20 Jan 2025 15:38:49 +0800 Subject: [PATCH] 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 --- manual/usage/backup_and_restore.md | 65 ++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 66 insertions(+) create mode 100644 manual/usage/backup_and_restore.md diff --git a/manual/usage/backup_and_restore.md b/manual/usage/backup_and_restore.md new file mode 100644 index 0000000..0b218f2 --- /dev/null +++ b/manual/usage/backup_and_restore.md @@ -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 +``` diff --git a/mkdocs.yml b/mkdocs.yml index eb07d8f..c3ad515 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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