jaeyson / ex_typesense

Typesense client for Elixir with support for importing your Ecto schemas.
https://hexdocs.pm/ex_typesense
MIT License
25 stars 7 forks source link

Making backups and restores (snapshots) #7

Open jaeyson opened 9 months ago

jaeyson commented 9 months ago

Based on docs, there are few points for making backups/restores (aka snapshots):

Backup steps

It is unsafe to directly archive/backup Typesense's data directory, since Typesense might have open files that it's writing to, as > the backup is being taken. Instead, you want to do the following:

  • Call the Snapshot API endpoint, specifying the directory to which to write the snapshot to on the server.
  • Backup this directory to remote storage, using say tar -czvf backup.tar.gz -C /tmp/typesense-data-snapshot .

Restore steps

  • Stop any running Typesense processes.
  • Delete the contents of the existing data dir. Eg: rm -rf /var/lib/typesense/*
  • Extract the tar gzip backup file to the data directory. Eg: cd /var/lib/typesense ; tar -xf backup.tar.gz .
  • Start the Typesense process again.

Typesense will then read the snapshot from the data dir and build the in-memory index.