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
- Variables
- func Create(ctx context.Context, home, file, version string, snapshot Snapshot) (*backupv1.BackupServiceCreateResponse, error)
- func DefaultFile(now time.Time) (string, error)
- func Finish(home string) ([]string, error)
- func Handler(db *store.Store, home, version string) (string, http.Handler)
- type Restored
- type Snapshot
Constants ¶
const (
// ManifestFile opens every archive: a backupv1.Manifest in JSON.
ManifestFile = "djinn-backup.json"
)
Variables ¶
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 ¶
DefaultFile is a new archive in the Downloads folder, named after now: .zip on Windows, .tar.gz elsewhere.
func Finish ¶ added in v0.2.0
Finish ends a restore of the data folder home that a stop cut, and removes what restores cut sooner left next to it; djinn up calls it before it opens home, and a restore before it starts. A stop between the restore's two renames left no data folder: the restored folder, extracted whole and marked, goes in place, and the worktrees of the folder put aside follow it. It returns what it did, one line each; none when there was nothing to do.
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 ¶
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.