backup

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package backup writes Djinn's data folder into one archive, and puts it back. The archive holds a consistent copy of the database and the files beside it: the pages, the window's state, the folders of the tasks. It leaves out what is rebuilt or held elsewhere: the worktrees (Git holds them), the socket, the server's address, the logs, and any environment file. Djinn stores no secret, so the archive holds none.

Index

Constants

View Source
const (
	// ManifestFile opens every archive: a backupv1.Manifest in JSON.
	ManifestFile = "djinn-backup.json"
)

Variables

View Source
var ErrRunning = errors.New("djinn is running on this data folder")

ErrRunning is returned by Restore when a djinn runs on the data folder.

Functions

func Create

func Create(ctx context.Context, home, file, version string, snapshot Snapshot) (*backupv1.BackupServiceCreateResponse, error)

Create writes the data folder home into the archive file, replacing it, and returns what it wrote. snapshot copies the database; the other files are read as they are. The archive appears whole or not at all.

func DefaultFile

func DefaultFile(now time.Time) (string, error)

DefaultFile is a new archive in the Downloads folder, named after now: .zip on Windows, .tar.gz elsewhere.

func Handler

func Handler(db *store.Store, home, version string) (string, http.Handler)

Handler serves BackupService on the database db of the data folder home: the djinn that holds the database copies it.

Types

type Restored

type Restored struct {
	// Home is the data folder restored.
	Home string
	// Aside is where the previous data folder was moved; empty when there was none.
	Aside string
	// Files restored, the database included.
	Files int
	// Detached are the projects whose folder is missing on this machine: djinn project add <folder> attaches each.
	Detached []string
}

Restored is what Restore did.

func Restore

func Restore(ctx context.Context, home, archive string, now time.Time) (*Restored, error)

Restore puts the archive back as the data folder home, while no djinn runs on it. The previous folder is kept aside, next to it; its worktrees move into the restored folder, at the same paths, so Git still finds them. A project whose folder this machine lacks loses it, so that djinn project add attaches it, as after an import.

type Snapshot

type Snapshot func(ctx context.Context, dst string) error

Snapshot copies the database, consistently, to dst, a file that does not exist yet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL