rapi

package module
v0.0.0-...-53483ec Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: BSD-2-Clause Imports: 31 Imported by: 4

README

Restic by Example

CI Status Go ReportCard

I'm trying to learn how restic works, and this repository relates my journey.

Tooling

This repository also provides some useful tooling for restic repositories. Please see the tooling documentation.

Target audience

This is not a user's guide, the official documentation is quite good at it.

This guide is for those of you willing to contribute to restic eventually, build tooling to augment restic’s ecosystem, or self-serve if something terrible happens with your data, empowering you to create the necessary tooling to troubleshot/fix/workaround things.

The guide

The guide only covers core restic operations. Things like the virtual filesystem, remote repository backends, the cache and some other things were intentionally left out. I may include then in a future advanced restic internal's guide.

0. Intro

1. Prerequisites

2. Restic IDs

3. File Encryption

4. Pack Files

5. Blobs

6. The Index

7. File Chunking TODO

8. Deduplication TODO

9. Recommended Reading

Note: this unofficial guide is a work in progress, from a random guy who's never contributed to restic before. You should take all this with a grain of salt until it's been reviewed by a few more eyes and this note is removed.

I may have introduced new bugs in restic's code while adapting it for this guide. Code or guide reviews and fixes for any errors found are greatly appreciated.

Credits

Most of the API code in this repository comes from restic. I've modified it so it can be used externally (moving code from internal to external packages) and added some helper functions that should make it a bit easier to use when dealing with local restic repositories.

Not all the code from restic's repository has been imported, just enough code to be able to read, write, decrypt and encrypt local repository files.

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05"

TimeFormat is the format used for all timestamps printed by restic.

Variables

View Source
var DefaultOptions = ResticOptions{
	// contains filtered or unexported fields
}

Functions

func ClearLine

func ClearLine() string

ClearLine creates a platform dependent string to clear the current line, so it can be overwritten. ANSI sequences are not supported on current windows cmd shell.

func OpenRepository

func OpenRepository(opts ResticOptions) (*repository.Repository, error)

OpenRepository reads the password and opens the repository.

func Print

func Print(args ...interface{})

Print writes the message to the configured stdout stream.

func PrintProgress

func PrintProgress(format string, args ...interface{})

PrintProgress wraps fmt.Printf to handle the difference in writing progress information to terminals and non-terminal stdout

func Printf

func Printf(format string, args ...interface{})

Printf writes the message to the configured stdout stream.

func Println

func Println(args ...interface{})

Println writes the message to the configured stdout stream.

func ReadPassword

func ReadPassword(opts ResticOptions, prompt string) (string, error)

ReadPassword reads the password from a password file, the environment variable RESTIC_PASSWORD or prompts the user.

func ReadPasswordTwice

func ReadPasswordTwice(gopts ResticOptions, prompt1, prompt2 string) (string, error)

ReadPasswordTwice calls ReadPassword two times and returns an error when the passwords don't match.

func ReadRepo

func ReadRepo(opts ResticOptions) (string, error)

func Verbosef

func Verbosef(format string, args ...interface{})

Verbosef calls Printf to write the message when the verbose flag is set.

func Verboseff

func Verboseff(format string, args ...interface{})

Verboseff calls Printf to write the message when the verbosity is >= 2

func Warnf

func Warnf(format string, args ...interface{})

Warnf writes the message to the configured stderr stream.

Types

type ResticOptions

type ResticOptions struct {
	Repo            string
	RepositoryFile  string
	PasswordFile    string
	PasswordCommand string
	KeyHint         string
	Quiet           bool
	Verbose         int
	NoLock          bool
	JSON            bool
	CacheDir        string
	NoCache         bool
	CACerts         []string
	TLSClientCert   string
	CleanupCache    bool

	LimitUploadKb   int
	LimitDownloadKb int

	Password string

	Options []string
	// contains filtered or unexported fields
}

ResticOptions hold all global options for restic.

Directories

Path Synopsis
Package backend provides local and remote storage for restic repositories.
Package backend provides local and remote storage for restic repositories.
b2
gs
Package gs provides a restic backend for Google Cloud Storage.
Package gs provides a restic backend for Google Cloud Storage.
local
Package local implements repository storage in a local directory.
Package local implements repository storage in a local directory.
location
Package location implements parsing the restic repository location from a string.
Package location implements parsing the restic repository location from a string.
mem
s3
sftp
Package sftp implements repository storage in a directory on a remote server via the sftp protocol.
Package sftp implements repository storage in a directory on a remote server via the sftp protocol.
test
Package test contains a test suite with benchmarks for restic backends.
Package test contains a test suite with benchmarks for restic backends.
cmd
rapi
* Restic snapshot related tools * * See https://github.com/rubiojr/rapi/tree/master/docs/tooling
* Restic snapshot related tools * * See https://github.com/rubiojr/rapi/tree/master/docs/tooling
Package crypto provides all cryptographic operations needed in restic.
Package crypto provides all cryptographic operations needed in restic.
index_blobs.go walks restic's repository data dir and adds all the blobs available the pack files found to an index map.
index_blobs.go walks restic's repository data dir and adds all the blobs available the pack files found to an index map.
internal
archiver
Package archiver contains the code which reads files, splits them into chunks and saves the data to the repository.
Package archiver contains the code which reads files, splits them into chunks and saves the data to the repository.
debug
Package debug provides an infrastructure for logging debug information and breakpoints.
Package debug provides an infrastructure for logging debug information and breakpoints.
errors
Package errors provides custom error types used within restic.
Package errors provides custom error types used within restic.
filter
Package filter implements filters for files similar to filepath.Glob, but in contrast to filepath.Glob a pattern may specify directories.
Package filter implements filters for files similar to filepath.Glob, but in contrast to filepath.Glob a pattern may specify directories.
fs
Package fs implements an OS independent abstraction of a file system suitable for backup purposes.
Package fs implements an OS independent abstraction of a file system suitable for backup purposes.
migrations
Package migrations contains migrations that can be applied to a repository and/or backend.
Package migrations contains migrations that can be applied to a repository and/or backend.
restorer
Package restorer contains code to restore data from a repository.
Package restorer contains code to restore data from a repository.
test
Package test provides helper functions for writing tests for restic.
Package test provides helper functions for writing tests for restic.
textfile
Package textfile allows reading files that contain text.
Package textfile allows reading files that contain text.
ui
Package pack provides functions for combining and parsing pack files.
Package pack provides functions for combining and parsing pack files.
Package repository implements a restic repository on top of a backend.
Package repository implements a restic repository on top of a backend.
Package restic is the top level package for the restic backup program, please see https://github.com/restic/restic for more information.
Package restic is the top level package for the restic backup program, please see https://github.com/restic/restic for more information.
Package test provides helper functions for writing tests for restic.
Package test provides helper functions for writing tests for restic.

Jump to

Keyboard shortcuts

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