Documentation
¶
Overview ¶
Package backup provides path validation helpers for backup operations.
Usage:
absPath, err := backup.ValidateBackupPath(cfg.Backup.Dir, userSuppliedPath)
Package backup provides backup creation, listing, restoration, verification, pruning, and WAL archiving for nSelf projects.
Package backup — create_remote.go: post-create encryption and remote (rclone) upload helpers used by createFullBackup. Split out of create_targets.go (file-size ratchet, internal/repoqa) as a pure move — no behavior change beyond what is documented on requireCompleteS3Credentials and uploadToRemote below.
Package backup — Hasura metadata export.
BackupHasuraMetadata calls the Hasura v1/metadata export_metadata API and writes the result to <backupDir>/hasura-metadata-<YYYY-MM-DD>.json. The file is mode 0600.
Package backup — streaming encrypted backup to remote destinations.
The pipeline runs three concurrent goroutines:
pg_dump (streaming) | age (encrypt) | rclone (multipart upload)
No temp files are written. Encryption recipients may be age public keys, SSH public keys, or GitHub user keys (fetched via github.com/users/<user>/keys). The upload destination is any rclone-supported remote: s3://, r2://, b2://, gcs://, az://.
Index ¶
- Constants
- func ArchiveWAL(ctx context.Context, opts ArchiveWALOptions) error
- func AutoKeyDisabled() bool
- func BackupHasuraMetadata(ctx context.Context, opts HasuraMetadataOptions) (string, error)
- func ConfigView(cfg *config.Config, format string) (string, error)
- func CountRows(ctx context.Context, c *Container) (map[string]int64, error)
- func Create(ctx context.Context, cfg *config.Config, opts CreateOptions) error
- func DefaultIdentity(project, flag string) (string, error)
- func FormatList(backups []BackupEntry, format string) (string, error)
- func FormatPruneJSON(w io.Writer, result *PruneResult, keepDaily int) error
- func FormatStatus(info *StatusInfo, format string) (string, error)
- func FormatStatusOffbox(info *StatusInfo, off *OffboxStatus, format string) (string, error)
- func IdentityPath(project string) (string, error)
- func InitKey(cfg *config.Config) (string, error)
- func InstallSystemdUnits(cfg *config.Config, opts SystemdInstallOptions) error
- func ListBackups(backupDir string) ([]string, error)
- func NewIdentityMissing(path, flag string) error
- func OpenDestination(uri string) (destinations.Destination, error)
- func ParseAge(s string) (time.Duration, error)
- func ReadApproxRows(ctx context.Context, pgURL string) (map[string]int64, error)
- func Restore(ctx context.Context, cfg *config.Config, opts RestoreOptions) error
- func RestoreFromRemote(ctx context.Context, cfg *config.Config, from, keyPath string) error
- func RestoreIntoContainer(ctx context.Context, c *Container, file string) error
- func ScheduleStream(cfg *config.Config, opts ScheduleOptions) error
- func ValidateBackupPath(backupDir, userPath string) (string, error)
- func WriteHeartbeat(ctx context.Context, remote string, hb Heartbeat) error
- type ArchiveWALOptions
- type BackupEntry
- type BackupType
- type Container
- type ContainerSpec
- type CreateOptions
- type DrillRemoteOptions
- type DrillRemoteResult
- type EmbeddedBackupResult
- type HasuraMetadataOptions
- type Heartbeat
- type Identity
- type ListOptions
- type OffboxOptions
- type OffboxStatus
- type PruneJSONEntry
- type PruneJSONReport
- type PruneOptions
- type PruneResult
- type RestoreOptions
- type ResumeOptions
- type ResumeState
- type ScheduleOptions
- type StatusInfo
- type StreamConfig
- type StreamOptions
- type StreamResult
- type SystemdInstallOptions
- type SystemdUnitFiles
- type VerifyOptions
- type VerifyResult
Constants ¶
const BackedUpMarkerSuffix = ".backed-up"
BackedUpMarkerSuffix names the empty file the owner creates next to the identity once it is copied somewhere other than this host. The doctor hint stays quiet only when it exists.
const HeartbeatSchemaVersion = "1"
HeartbeatSchemaVersion is the contract version written to every object.
const NoAutoKeyEnv = "NSELF_BACKUP_NO_AUTO_KEY"
NoAutoKeyEnv set to 1 keeps the fail-closed refusal when no recipient is configured.
Variables ¶
This section is empty.
Functions ¶
func ArchiveWAL ¶ added in v1.0.6
func ArchiveWAL(ctx context.Context, opts ArchiveWALOptions) error
ArchiveWAL encrypts and uploads a single WAL file to the remote. This is the core logic for the nself-backup-archive helper binary.
func AutoKeyDisabled ¶ added in v1.4.13
func AutoKeyDisabled() bool
AutoKeyDisabled reports whether NSELF_BACKUP_NO_AUTO_KEY=1.
func BackupHasuraMetadata ¶ added in v1.0.14
func BackupHasuraMetadata(ctx context.Context, opts HasuraMetadataOptions) (string, error)
BackupHasuraMetadata exports Hasura metadata and saves it to BackupDir. Returns the path of the written file.
func ConfigView ¶ added in v1.0.6
ConfigView returns the current backup configuration as a formatted string.
func CountRows ¶ added in v1.4.13
CountRows returns the exact count(*) of every user table, key "schema.table".
func Create ¶ added in v1.0.6
Create performs a backup of the specified type. It writes the backup to the local backup directory and optionally uploads to the configured remote.
func DefaultIdentity ¶ added in v1.4.13
DefaultIdentity finds the identity to decrypt with when no key flag was given: <project>-age.key (init-key and the auto identity), then <project>-backup-age.key, then age-key.txt, under ~/.config/nself. Each candidate that exists must be a regular, non-symlink file that parses as an age identity, otherwise E222 names it. None found is E223 naming flag, the command's own key flag. An explicit key path never comes through here.
func FormatList ¶ added in v1.0.6
func FormatList(backups []BackupEntry, format string) (string, error)
FormatList renders backup entries as a table or JSON string.
func FormatPruneJSON ¶ added in v1.0.6
func FormatPruneJSON(w io.Writer, result *PruneResult, keepDaily int) error
FormatPruneJSON writes a PruneResult as JSON to w (the caller's stream).
func FormatStatus ¶ added in v1.0.6
func FormatStatus(info *StatusInfo, format string) (string, error)
FormatStatus renders status info as a string.
func FormatStatusOffbox ¶ added in v1.4.13
func FormatStatusOffbox(info *StatusInfo, off *OffboxStatus, format string) (string, error)
FormatStatusOffbox renders the status with the off-box heartbeat state. info is nil outside a project directory (--project with --heartbeat-to): then only the offbox object (JSON) or the two off-box lines (text) are printed. The text form gains the two lines only when a heartbeat remote is configured.
func IdentityPath ¶ added in v1.4.13
IdentityPath returns ~/.config/nself/<project>-age.key.
func InitKey ¶ added in v1.0.6
InitKey generates an age keypair for backup encryption. Private key: ~/.config/nself/{project}-age.key (mode 0600) Public key: written to BACKUP_AGE_RECIPIENTS in the project .env.
func InstallSystemdUnits ¶ added in v1.0.6
func InstallSystemdUnits(cfg *config.Config, opts SystemdInstallOptions) error
InstallSystemdUnits renders and writes unit files, then runs `systemctl daemon-reload` and enables each timer. Requires root.
func ListBackups ¶
ListBackups returns the names of all regular files in backupDir. The returned slice is empty (not nil) when the directory contains no files. Directories and other non-regular entries are skipped.
func NewIdentityMissing ¶ added in v1.4.13
NewIdentityMissing is the E223 error for a decrypt that has no identity; flag is the key flag of the command that failed.
func OpenDestination ¶ added in v1.4.13
func OpenDestination(uri string) (destinations.Destination, error)
OpenDestination parses uri; a host:// URI loads the inventory of the current directory.
func ParseAge ¶ added in v1.4.13
ParseAge parses a duration that also accepts days: "26h", "35d", "1d12h".
func ReadApproxRows ¶ added in v1.4.13
ReadApproxRows returns {"<schema>.<table>": n_live_tup} from pg_stat_user_tables. It must run before the dump starts.
func RestoreFromRemote ¶ added in v1.0.12
RestoreFromRemote decrypts and restores a backup directly from a remote URL. It streams: rclone cat | age -d | pg_restore. No local temp file.
func RestoreIntoContainer ¶ added in v1.4.13
RestoreIntoContainer restores file into the container. The format comes from the content, never the extension: a file that starts with the PGDMP magic is a custom-format archive (pg_restore --no-owner --no-acl, since production roles do not exist here), anything else is plain SQL (psql). Stream backups are custom-format archives named .sql.
func ScheduleStream ¶ added in v1.0.12
func ScheduleStream(cfg *config.Config, opts ScheduleOptions) error
ScheduleStream installs a systemd timer for `nself backup stream`, run in the real project with the running binary.
WorkingDirectory is the resolved project directory (the one loadProjectConfig uses: the current directory), ExecStart is the absolute path of the running binary with symlinks resolved, and the unit has no EnvironmentFile line unless opts.EnvFile is set. Nothing is guessed: the unit that was previously written pointed at /opt/nself and /usr/local/bin/nself, which exist on no real project.
func ValidateBackupPath ¶
ValidateBackupPath resolves userPath relative to backupDir and verifies that the resolved absolute path is contained within backupDir. This prevents path traversal attacks (e.g. "../../../etc/passwd").
backupDir is the trusted root directory for backups (e.g. "/var/backups"). userPath is the caller-supplied relative or absolute path.
Returns the resolved absolute path on success, or an error if the path escapes backupDir.
Types ¶
type ArchiveWALOptions ¶ added in v1.0.6
type ArchiveWALOptions struct {
WALFile string // path to local WAL file
Remote string // rclone remote path
AgeRecipient string // age public key for encryption
Timeline string // PG timeline ID
MaxRetries int // max upload retries (default: 3)
RetryInterval time.Duration
}
ArchiveWALOptions holds configuration for WAL file archiving.
type BackupEntry ¶ added in v1.0.6
type BackupEntry struct {
ID string `json:"id"`
Date time.Time `json:"date"`
Size int64 `json:"size"`
Type string `json:"type"` // full, metadata, minio, wal
Tag string `json:"tag"` // user tag if present
Encrypted bool `json:"encrypted"` // .age suffix
}
BackupEntry holds parsed metadata for a single backup file.
func List ¶ added in v1.0.6
func List(cfg *config.Config, opts ListOptions) ([]BackupEntry, error)
List returns backup entries from the local backup directory, or from the destination named by opts.Remote (rclone remote, path:// or host://).
type BackupType ¶ added in v1.0.6
type BackupType string
BackupType identifies the kind of backup to create.
const ( BackupTypeFull BackupType = "full" BackupTypeWAL BackupType = "wal" BackupTypeMetadata BackupType = "metadata" BackupTypeMinio BackupType = "minio" BackupTypeAll BackupType = "all" )
type Container ¶ added in v1.4.13
type Container struct {
Name, User, DB, Volume string
// contains filtered or unexported fields
}
Container is a started postgres container.
func StartContainer ¶ added in v1.4.13
func StartContainer(ctx context.Context, spec ContainerSpec) (*Container, error)
StartContainer starts the container and waits until postgres accepts TCP connections on its own loopback (the init server listens on the socket only, so this cannot return before the final server is up).
type ContainerSpec ¶ added in v1.4.13
type ContainerSpec struct {
Name string // "" = throwaway; otherwise must end in _pg_restore_test
Volume string // named data volume ("" = anonymous, removed with the container)
User string
DB string
Password string // "" = random
Image string
Keep bool // leave the container for inspection
Ready time.Duration // wait for postgres; default 60s
}
ContainerSpec describes the container to start. A zero Name selects a throwaway drill container (random name, random password, no network).
type CreateOptions ¶ added in v1.0.6
type CreateOptions struct {
Type BackupType // full, wal, metadata, minio, all
Remote string // remote name override
Encrypt bool // force encryption on
NoEncrypt bool // force encryption off
Tag string // human label for this backup
DryRun bool // preview only
}
CreateOptions holds flags for `nself backup create`.
type DrillRemoteOptions ¶ added in v1.4.13
type DrillRemoteOptions struct {
Project string
From string // destination holding <project>_stream_* objects
Key string // object to restore; "" = newest
Identity string // age identity file; "" = default locations
HeartbeatTo string // heartbeat remote; "" = drill.json is not written
}
DrillRemoteOptions are the inputs of DrillRemote.
type DrillRemoteResult ¶ added in v1.4.13
type DrillRemoteResult struct {
Heartbeat Heartbeat
Tables []string // restored tables, sorted
Estimated bool // row estimates from the backup heartbeat were used
HeartbeatWritten bool
Warnings []string // why source counts were not used, key mismatches
Duration time.Duration
}
DrillRemoteResult is the outcome of a drill. Heartbeat is what drill.json holds.
func DrillRemote ¶ added in v1.4.13
func DrillRemote(ctx context.Context, o DrillRemoteOptions) (*DrillRemoteResult, error)
DrillRemote runs the drill. It returns a non-nil result whenever the restore was attempted, with the error that made it fail. A cancelled ctx (SIGINT, SIGTERM) unwinds through the defers that remove the container and the decrypted files and writes no heartbeat.
type EmbeddedBackupResult ¶ added in v1.1.3
type EmbeddedBackupResult struct {
// ArtifactPath is the absolute path of the produced backup file.
ArtifactPath string
// Format is "pgdump-custom" when pg_dump was used, or "sql-plain" when
// the wire-protocol COPY fallback was used.
Format string
}
EmbeddedBackupResult describes the outcome of an embedded PG backup operation.
func BackupEmbedded ¶ added in v1.1.3
BackupEmbedded creates a backup of the embedded pglite database. It first attempts to use pg_dump (pointing at the UDS socket) to produce a pg_dump-custom-format artifact compatible with pg_restore. If pg_dump is not available on PATH, it falls back to a wire-protocol SQL dump via pgx.
The artifact is written atomically (to a temp file then renamed) to prevent partial backup files from being visible to concurrent readers.
The backup file name format: <timestamp>-embedded.dump (pg custom format)
or: <timestamp>-embedded.sql (SQL fallback)
type HasuraMetadataOptions ¶ added in v1.0.14
type HasuraMetadataOptions struct {
// HasuraURL is the base URL of the Hasura instance, e.g.
// "http://localhost:8080". Defaults to "http://localhost:8080".
HasuraURL string
// AdminSecret is the Hasura admin secret used for authentication.
AdminSecret string
// BackupDir is the directory where the JSON file will be written.
// Defaults to "./backups".
BackupDir string
}
HasuraMetadataOptions holds parameters for BackupHasuraMetadata.
type Heartbeat ¶ added in v1.4.13
type Heartbeat struct {
ApproxRows map[string]int64 `json:"approx_rows"` // backup: estimates, null when unreadable
At string `json:"at"` // RFC 3339 UTC, upload finish time
BackupKey string `json:"backup_key"` // object key, never the remote
Bytes int64 `json:"bytes"` // size of the (encrypted) object
CLIVersion string `json:"cli_version"`
Encrypted bool `json:"encrypted"`
Kind string `json:"kind"`
Mismatches []string `json:"mismatches"` // drill only; [] for a backup
Project string `json:"project"`
RestoredRows map[string]int64 `json:"restored_rows"` // drill only; null for a backup
Result string `json:"result"`
SchemaVersion string `json:"schema_version"`
}
Heartbeat is the backup.json object. Fields are declared in sorted JSON-key order so encoding/json writes them sorted; TestHeartbeatGoldenShape pins it.
func ParseHeartbeat ¶ added in v1.4.13
ParseHeartbeat validates a heartbeat object. Unknown fields are accepted (additive fields stay v1); everything else must match the contract.
type Identity ¶ added in v1.4.13
type Identity struct {
Path string
Recipient string // public key, safe to print
Created bool // true when this call created the file
}
Identity describes an age identity file. The secret is never held here.
func EnsureIdentity ¶ added in v1.4.13
EnsureIdentity returns the project's identity, creating it when absent. An existing identity is never replaced; wider-than-0600 modes are tightened.
type ListOptions ¶ added in v1.0.6
type ListOptions struct {
Remote string // filter by remote name
Env string // filter by environment
Since time.Duration // only show backups newer than this
Format string // table or json
}
ListOptions holds flags for `nself backup list`.
type OffboxOptions ¶ added in v1.4.13
OffboxOptions are the thresholds; zero means "not checked".
type OffboxStatus ¶ added in v1.4.13
type OffboxStatus struct {
Source string `json:"source"` // "heartbeat" or "none"
LastBackup *Heartbeat `json:"last_backup"`
LastDrill *Heartbeat `json:"last_drill"`
BackupAgeSeconds *int64 `json:"backup_age_seconds"`
DrillAgeSeconds *int64 `json:"drill_age_seconds"`
MaxAgeExceeded bool `json:"max_age_exceeded"`
MaxDrillAgeExceeded bool `json:"max_drill_age_exceeded"`
// Problems lists the reason of every missing, stale, failed or unreadable
// heartbeat ("[E219] ..."); an empty array when none. Additive in v1.
Problems []string `json:"problems"`
}
OffboxStatus is the `offbox` object of `nself backup status --format json`. Field order is the contract order.
func ReadOffbox ¶ added in v1.4.13
func ReadOffbox(ctx context.Context, remote, project string, opts OffboxOptions, now time.Time) (*OffboxStatus, error)
ReadOffbox reads both heartbeats and applies the thresholds. The returned status is always usable; err is nil, one coded error, or several joined.
func (*OffboxStatus) Lines ¶ added in v1.4.13
func (s *OffboxStatus) Lines() []string
Lines renders the two human lines of `backup status`.
type PruneJSONEntry ¶ added in v1.0.6
PruneJSONEntry is one entry in the would_delete or kept arrays.
type PruneJSONReport ¶ added in v1.0.6
type PruneJSONReport struct {
DryRun bool `json:"dry_run"`
KeepDaily int `json:"keep_daily"`
WouldDelete []PruneJSONEntry `json:"would_delete"`
Kept []PruneJSONEntry `json:"kept"`
}
PruneJSONReport is the machine-readable output of `backup prune --format json`.
func BuildPruneReport ¶ added in v1.4.13
func BuildPruneReport(result *PruneResult, keepDaily int) PruneJSONReport
BuildPruneReport turns a PruneResult into the machine-readable report.
type PruneOptions ¶ added in v1.0.6
PruneOptions holds flags for `nself backup prune`.
type PruneResult ¶ added in v1.0.6
PruneResult summarizes what was (or would be) pruned.
func Prune ¶ added in v1.0.6
func Prune(cfg *config.Config, opts PruneOptions) (*PruneResult, error)
Prune removes old backups according to the retention policy. Retention: keep last N daily, N weekly (Sundays), N monthly (1st of month). Backups tagged "keep" are never deleted. WAL segments newer than the oldest surviving base backup are never deleted.
type RestoreOptions ¶ added in v1.0.6
type RestoreOptions struct {
BackupID string // backup ID or "latest"
ToDir string // restore to alternate directory
Only []string // pg, minio, metadata — subset to restore
DecryptKey string // path to age identity file
Yes bool // skip confirmation
}
RestoreOptions holds flags for `nself backup restore`.
Note: PointInTime (PITR) is NOT supported in v1.0.9. The field is retained for forward compatibility but any non-empty value returns an explicit error directing users to v1.1.0 + pgbackrest integration. Remove this note when PITR ships.
type ResumeOptions ¶ added in v1.0.12
type ResumeOptions struct {
BackupID string
}
ResumeOptions holds flags for `nself backup resume`.
type ResumeState ¶ added in v1.0.12
type ResumeState struct {
BackupID string `json:"backup_id"`
Destination string `json:"destination"`
Key string `json:"key"`
Recipients []string `json:"recipients"`
StartedAt time.Time `json:"started_at"`
// For rclone-based multipart, we store the partial object key prefix.
// rclone handles actual part tracking internally; we record enough to
// invoke rclone copyto from a local temp file on resume.
PartialPath string `json:"partial_path,omitempty"`
}
ResumeState holds the persisted state for a resumable streaming backup.
type ScheduleOptions ¶ added in v1.4.13
type ScheduleOptions struct {
Cron string
To string // rclone destination; falls back to cfg.Backup.Remote
Recipients []string // repeatable --recipient, written as repeated flags
HeartbeatTo string // --heartbeat-to, written into the unit when given
EnvFile string // --env-file; no EnvironmentFile line when empty
UnitDir string // default /etc/systemd/system
DryRun bool
Out io.Writer // dry-run output; default os.Stdout
BinaryPath string
ProjectDir string
}
ScheduleOptions holds the inputs of ScheduleStream (flags of `nself backup schedule`). BinaryPath and ProjectDir are test seams: left empty they resolve to the running binary and the current project directory.
type StatusInfo ¶ added in v1.0.6
type StatusInfo struct {
LastRun string `json:"last_run"`
NextRun string `json:"next_run"`
Health string `json:"health"` // healthy, warning, error
TotalSize string `json:"total_size"`
BackupCount int `json:"backup_count"`
RetentionDaily int `json:"retention_daily"`
RetentionWeekly int `json:"retention_weekly"`
RetentionMonthly int `json:"retention_monthly"`
}
StatusInfo holds backup subsystem status.
type StreamConfig ¶ added in v1.0.12
type StreamConfig struct {
// PgURL is the postgres DSN used by pg_dump. If empty, derived from cfg.
PgURL string
// Destination is the rclone remote path, e.g. "s3:bucket/prefix/".
Destination string
// Recipients holds age/SSH public keys (one per entry). May also be
// "github:<username>" to fetch the user's SSH public keys from GitHub.
Recipients []string
// Key is the object name appended to Destination. Auto-generated if empty.
Key string
// ChunkMB is the multipart chunk size. Defaults to 64.
ChunkMB int
}
StreamConfig holds parameters for a streaming encrypted backup.
type StreamOptions ¶ added in v1.0.12
type StreamOptions struct {
To string // destination URL (rclone remote path)
Recipients []string // --recipient flags (may be specified multiple times)
DryRun bool
// AllowUnencrypted permits streaming in the clear when no recipient
// resolves. Off by default: without it, a missing recipient is an error
// rather than a silent plaintext upload. See the check in Stream.
AllowUnencrypted bool
// HeartbeatTo is the rclone remote that receives <project>/backup.json
// after a successful upload (--heartbeat-to). Empty falls back to
// NSELF_BACKUP_HEARTBEAT_REMOTE; with neither, no heartbeat is written.
HeartbeatTo string
// HeartbeatRequired makes Stream return an error when the heartbeat cannot
// be written (--heartbeat-required). Off by default: a heartbeat outage
// must never lose or fail the backup itself.
HeartbeatRequired bool
}
StreamOptions holds CLI flag values for `nself backup stream`.
type StreamResult ¶ added in v1.0.12
type StreamResult struct {
BackupID string `json:"backup_id"`
Destination string `json:"destination"`
StartedAt time.Time `json:"started_at"`
Duration string `json:"duration"`
Encrypted bool `json:"encrypted"`
// Bytes is the size of the uploaded (encrypted) object.
Bytes int64 `json:"bytes,omitempty"`
}
StreamResult is returned by Stream on success.
func Resume ¶ added in v1.0.12
func Resume(ctx context.Context, cfg *config.Config, opts ResumeOptions) (*StreamResult, error)
Resume attempts to complete a previously interrupted streaming backup. Since rclone rcat cannot resume a partial upload, Resume re-streams from pg_dump through the full pipeline. The previous partial upload is overwritten at the same destination key.
func Stream ¶ added in v1.0.12
func Stream(ctx context.Context, cfg *config.Config, opts StreamOptions) (*StreamResult, error)
Stream runs a three-stage concurrent pipeline:
- pg_dump stdout -> pgWriter
- age encrypts pgReader -> encWriter (skipped if no recipients)
- rclone rcat uploads encReader to Destination/Key
All three stages run in parallel goroutines. The first error from any stage cancels the others via context cancellation.
When a heartbeat remote is set (opts.HeartbeatTo or NSELF_BACKUP_HEARTBEAT_REMOTE) the row estimates are read before the dump starts and, only after the upload succeeded, <project>/backup.json is written there. A heartbeat failure is logged; it is returned (together with the successful result) only when opts.HeartbeatRequired is set.
type SystemdInstallOptions ¶ added in v1.0.6
type SystemdInstallOptions struct {
FullAt string // "HH:MM" UTC, e.g. "02:00"
WALEvery string // e.g. "15m"
PruneAt string // "HH:MM" UTC, default "04:30"
VerifyOnDay string // systemd OnCalendar day name (Sun..Sat), default "Sun"
VerifyAt string // "HH:MM", default "05:00"
UnitDir string // default /etc/systemd/system
EnvFile string // default /etc/nself/backup.env
BinaryPath string // default /usr/local/bin/nself
ProjectDir string // working directory for nself commands
Remote string // e.g. b2-nclaw
DryRun bool
}
SystemdInstallOptions controls install of nself-backup systemd units.
type SystemdUnitFiles ¶ added in v1.0.6
SystemdUnitFiles maps filename -> unit contents.
func RenderSystemdUnits ¶ added in v1.0.6
func RenderSystemdUnits(cfg *config.Config, opts SystemdInstallOptions) (SystemdUnitFiles, error)
RenderSystemdUnits produces the unit files needed for unattended backup, verify, and prune without writing to disk. Returns a map suitable for writing into /etc/systemd/system.
type VerifyOptions ¶ added in v1.0.6
type VerifyOptions struct {
BackupID string // backup ID or "latest"
RestoreTest bool // spin up test container and restore
Cleanup bool // remove test container after verify
Keep bool // keep test container for inspection
}
VerifyOptions holds flags for `nself backup verify`.
type VerifyResult ¶ added in v1.0.6
type VerifyResult struct {
BackupID string `json:"backup_id"`
Verified bool `json:"verified"`
StartedAt time.Time `json:"started_at"`
Duration string `json:"duration"`
Method string `json:"method"` // checksum, restore-test
Details string `json:"details"`
}
VerifyResult holds the outcome of a backup verification.
func Verify ¶ added in v1.0.6
func Verify(ctx context.Context, cfg *config.Config, opts VerifyOptions) (*VerifyResult, error)
Verify checks backup integrity, optionally performing a restore test.
Source Files
¶
- archive.go
- autokey.go
- backup.go
- config_cmd.go
- create.go
- create_remote.go
- create_targets.go
- drill_remote.go
- drill_support.go
- drill_sweep.go
- drill_verify.go
- embedded.go
- hasura_metadata.go
- heartbeat.go
- initkey.go
- list.go
- offbox_status.go
- prune.go
- prune_format.go
- restore.go
- restore_container.go
- stream.go
- stream_exec.go
- stream_restore.go
- stream_restore_remote.go
- stream_resume.go
- stream_schedule.go
- systemd.go
- verify.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package destinations — destination.go: the Destination interface, Parse and the kind registry.
|
Package destinations — destination.go: the Destination interface, Parse and the kind registry. |
|
Package pitr implements point-in-time recovery via pg_basebackup and WAL archiving.
|
Package pitr implements point-in-time recovery via pg_basebackup and WAL archiving. |