schellyhook

package module
v0.0.0-...-b32838e Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 10 Imported by: 1 module, 1 package

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.

README

schelly-webhook

Base library for creating Schelly Webhooks for creating specific backup providers that will be managed by Schelly

If you with to create a project in your own, feel free to fork https://github.com/flaviostutz/schelly-restic and change accordingly.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentBackupStartTime time.Time

CurrentBackupStartTime start time of currently running backup, if any

View Source
var RunningBackupAPIID = ""

RunningBackupAPIID current apiID of the currently running backup, if any

Functions

func ExecShell

func ExecShell(command string) (string, error)

ExecShell execute a shell command (like bash -c 'your command')

func ExecShellTimeout

func ExecShellTimeout(command string, timeout time.Duration, ctx *ShellContext) (string, error)

ExecShellTimeout execute a shell command (like bash -c 'your command') with a timeout. After that time, the process will be cancelled

func GetCmdOutput

func GetCmdOutput(cmd *cmd.Cmd) string

GetCmdOutput join stdout and stderr in a single string from Cmd

func Initialize

func Initialize(backuper Backuper) error

Initialize must be invoked to start REST server along with all Backuper hooks

Types

type Backuper

type Backuper interface {
	//Init register command line flags here etc
	Init() error
	//RegisterFlags register flags for command line options
	RegisterFlags() error
	//CreateNewBackup create a new backup synchronously (return only after complete backup creation). If you set shellContext.CmdRef when calling a Shell Script, the bridge will cancel the process automatically if a DELETE /backup/{id} for the running backup is received
	CreateNewBackup(apiID string, timeout time.Duration, shellContext *ShellContext) error
	//DeleteBackup remove backup data from storage. if backup is still running and set cmdRef on ShellContext of CreateBackup call, cancel it
	DeleteBackup(apiID string) error
	//GetAllBackups returns all tracked backups. this is optional for Schelly
	GetAllBackups() ([]SchellyResponse, error)
	//GetBackup returns a specific backup info. if requested apiID is running, this method is not even called, because schellyhook will do this for you
	GetBackup(apiID string) (*SchellyResponse, error)
}

Backuper interface for who is implementing specific backup operations on backend

type Options

type Options struct {
	ListenPort        int
	ListenIP          string
	PrePostTimeout    int
	PreBackupCommand  string
	PostBackupCommand string
}

Options command line options

type SchellyResponse

type SchellyResponse struct {
	ID      string  `json:"id",omitempty`
	DataID  string  `json:"data_id",omitempty`
	Status  string  `json:"status",omitempty`
	Message string  `json:"message",omitempty`
	SizeMB  float64 `json:"size_mb",omitempty`
}

SchellyResponse schelly webhook response

type ShellContext

type ShellContext struct {
	//CmdRef cmd.Cmd pointer that can be used to set command references that should be killed when a backup deletion of a running job is detected
	CmdRef *cmd.Cmd
}

ShellContext container to transport a Cmd reference

Directories

Path Synopsis
sample module

Jump to

Keyboard shortcuts

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