No description
Find a file
autocommit 05ca895a97
Some checks failed
Build and Publish / build-and-publish (push) Failing after 41s
deps-upgrade(dependencies): ⬆️ Update all dependencies to latest stable versions for bug fixes and improvements
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-06-11 01:19:51 -07:00
.forgejo/workflows fix(ci): fix backslash-bang syntax error in workflow 2026-01-30 15:49:43 -08:00
.turbo chore: initial commit 2026-01-21 11:37:38 -08:00
dist chore(gitignore): Add missing patterns 2026-01-21 15:33:14 -08:00
node_modules chore(gitignore): Add missing patterns 2026-01-21 15:33:14 -08:00
src chore: initial commit 2026-01-21 11:37:38 -08:00
.gitignore chore(gitignore): Add missing patterns 2026-01-21 15:33:14 -08:00
package.json deps-upgrade(dependencies): ⬆️ Update all dependencies to latest stable versions for bug fixes and improvements 2026-06-11 01:19:51 -07:00
README.md chore: trigger CI publish 2026-01-30 16:01:49 -08:00
tsconfig.json chore: initial commit 2026-01-21 11:37:38 -08:00
tsup.config.ts chore(build): 🔧 Update tsup config for optimized output with source maps enabled 2026-01-21 15:33:27 -08:00

@lilith/restic-restore

Restore workstation backups from restic REST server for disaster recovery.

Features

  • List snapshots: Browse available backups
  • Restore backups: Restore to local or remote hosts
  • Remote restore: SSH-based restore to new workstation
  • Flexible targeting: Include/exclude patterns support
  • Progress tracking: Detailed restore statistics

Installation

pnpm add @lilith/restic-restore

Usage

Programmatic API

import { restoreBackup, listSnapshots } from '@lilith/restic-restore'

// List available snapshots
const snapshots = await listSnapshots({
  repositoryUrl: 'rest:http://10.0.0.11:8000/apricot-code',
  password: 'your-restic-password',
  hostname: 'apricot',
})

// Restore to local path
await restoreBackup({
  repositoryUrl: 'rest:http://10.0.0.11:8000/apricot-code',
  password: 'your-restic-password',
  targetPath: '/tmp/restore',
  snapshotId: 'latest',
})

// Restore to remote host via SSH
await restoreBackup({
  repositoryUrl: 'rest:http://10.0.0.11:8000/apricot-dotfiles',
  password: 'your-restic-password',
  targetPath: '/home/user',
  remoteHost: 'user@10.0.0.64',
  snapshotId: 'latest',
})

CLI

# List snapshots
restic-restore list \
  --repo rest:http://10.0.0.11:8000/apricot-code \
  --password your-password

# Restore locally
restic-restore restore \
  --repo rest:http://10.0.0.11:8000/apricot-code \
  --password your-password \
  --target ~/Code

# Restore to remote host
restic-restore restore \
  --repo rest:http://10.0.0.11:8000/apricot-dotfiles \
  --password your-password \
  --target /home/user \
  --remote user@10.0.0.64

API

restoreBackup(options)

Restore backup from restic repository.

Options:

  • repositoryUrl (string): Restic REST server URL
  • password (string): Repository password
  • targetPath (string): Restore destination
  • snapshotId (string, optional): Snapshot to restore (default: 'latest')
  • remoteHost (string, optional): SSH host for remote restore
  • sshKey (string, optional): SSH key path (default: ~/.ssh/id_ed25519)
  • include (string[], optional): Include patterns
  • exclude (string[], optional): Exclude patterns
  • verbose (boolean, optional): Verbose output

Returns: Promise<RestoreResult>

listSnapshots(options)

List available snapshots in repository.

Options:

  • repositoryUrl (string): Restic REST server URL
  • password (string): Repository password
  • hostname (string, optional): Filter by hostname
  • tags (string[], optional): Filter by tags

Returns: Promise<ListSnapshotsResult>

getLatestSnapshot(options)

Get the most recent snapshot for a hostname.

Returns: Promise<ResticSnapshot | null>

Disaster Recovery Workflow

import { restoreBackup } from '@lilith/restic-restore'
import { restoreVaultBackup } from '@lilith/vault-setup-backup'
import { setupClient } from '@lilith/restic-setup-client'

// 1. Restore vault backup to get restic password
const vaultRestore = await restoreVaultBackup({
  backupPath: '~/Documents/VaultBackups/vault-backup-latest.enc',
  masterPassword: 'user-master-password',
  destination: '/tmp/vault',
})

// 2. Read restic password from restored vault
const resticPassword = fs.readFileSync('/tmp/vault/restic-password.txt', 'utf8').trim()

// 3. Restore code backup to new host
await restoreBackup({
  repositoryUrl: 'rest:http://10.0.0.11:8000/apricot-code',
  password: resticPassword,
  targetPath: '/home/user/Code',
  remoteHost: 'user@10.0.0.64',
})

// 4. Restore dotfiles backup
await restoreBackup({
  repositoryUrl: 'rest:http://10.0.0.11:8000/apricot-dotfiles',
  password: resticPassword,
  targetPath: '/home/user',
  remoteHost: 'user@10.0.0.64',
})

// 5. Setup restic client on restored host
await setupClient({
  serverUrl: 'http://10.0.0.11:8000',
  hostname: 'apricot',
  password: resticPassword,
  configDir: '~/.config/restic',
})

Requirements

  • Node.js 18+
  • restic binary installed on the system (or remote host for SSH restore)
  • SSH access for remote restores

License

UNLICENSED