No description
|
Some checks failed
Build and Publish / build-and-publish (push) Failing after 41s
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| .turbo | ||
| dist | ||
| node_modules | ||
| src | ||
| .gitignore | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
@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 URLpassword(string): Repository passwordtargetPath(string): Restore destinationsnapshotId(string, optional): Snapshot to restore (default: 'latest')remoteHost(string, optional): SSH host for remote restoresshKey(string, optional): SSH key path (default: ~/.ssh/id_ed25519)include(string[], optional): Include patternsexclude(string[], optional): Exclude patternsverbose(boolean, optional): Verbose output
Returns: Promise<RestoreResult>
listSnapshots(options)
List available snapshots in repository.
Options:
repositoryUrl(string): Restic REST server URLpassword(string): Repository passwordhostname(string, optional): Filter by hostnametags(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+
resticbinary installed on the system (or remote host for SSH restore)- SSH access for remote restores
License
UNLICENSED