# Backups

Archive format and verified import.

[Read the backups guide](/docs/backups/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## Backup


```ts
interface Backup {
  format: "nostrbase-backup";
  version: 1;
  namespace: string;
  exportedAt: number;
  events: NostrEvent[];
}
```

## BackupImport


```ts
interface BackupImport {
  imported: number;
  duplicates: number;
}
```

## belongsToNamespace


```ts
declare function belongsToNamespace(
  event: NostrEvent,
  namespace: string,
  known?: ReadonlySet<string>,
): boolean;
```

## NostrbaseBackup


```ts
declare class NostrbaseBackup {}
```

### constructor


```ts
constructor(host: BackupHost);
```

### export


```ts
export(): Promise<Result<Backup>>;
```

### import


```ts
import(input: Backup | string): Promise<Result<BackupImport>>;
```


## Supporting declarations

These types appear in public signatures but are not package exports.

### BackupHost


```ts
interface BackupHost {
  namespace: string;
  eventStore: EventStore;
  cachedEvents(): NostrEvent[];
  ready(): Promise<void>;
  assertOpen(): void;
  ingest(event: NostrEvent): boolean;
}
```
