How do I migrate a host history if I reset the machine?

Hello,

I’m self-hosting atuin and I have 3 hosts (machines) connected to it. Everything’s working perfectly. What I am curious to know is, let’s say I want to format one of the machines and re-install my OS, how could I reconnect and bind/associate the “new” machine with the pre-existing host history? i.e. without atuin thinking that I now have 4 hosts. It should still be 3 hosts.

I haven’t been able to find a solution so I naively created this backup script that runs on a schedule. I say naively because I don’t really know if restoration works.

#!/bin/bash

ROOT_DIR=${XDG_DATA_HOME:-${HOME}/.local/share}
ATUIN_DIR=${ROOT_DIR}/atuin
BACKUP_DIR=${HOME}/backup/atuin

fd -e db . "${ATUIN_DIR}" -x sqlite3 {} 'VACUUM;'
tar -C "${ROOT_DIR}" -czf "${BACKUP_DIR}/${HOSTNAME}-$(date +%Y%m%d).tar.gz" atuin
find "${BACKUP_DIR}" -name "${HOSTNAME}-*" -type f -printf '%T@ %p\n' \
  | sort -nr \
  | sed '1,5d' \
  | awk '{print $NF}' \
  | xargs -r rm
  1. Vacuum databases.
  2. Archive and compress the directory.
  3. Keep only the last 5 archives.