cmd

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigKey = "IBACKUP_CONFIG"
)

Variables

View Source
var (
	ErrCancel       = errors.New("cancelled add")
	ErrDuplicateSet = errors.New(
		"set with this name already exists, please choose a different name " +
			"or use ibackup edit to update it",
	)
)
View Source
var (
	ErrInvalidEditRO              = errors.New("you can either make a set read-only or writable, not both")
	ErrInvalidEditArchive         = errors.New("you can either --archive a set or --stop-archiving, not both")
	ErrInvalidEditFreeze          = errors.New("you can either --freeze a set or --stop-freeze, not both")
	ErrInvalidEditHide            = errors.New("you can either --hide or --unhide a set, not both")
	ErrInvalidEditMonitor         = errors.New("you can either --monitor or --stop-monitor a set, not both")
	ErrInvalidEditMonitorRemovals = errors.New("you can either --monitor-removals or " +
		"--stop-monitor-removals a set, not both")
	ErrInvalidEditMonitorRemovalsUnmonitored = errors.New("cannot use --monitor-removals without " +
		"--monitor or set being monitored")
	ErrEditItemsNotAdmin = errors.New("only admins can use --add-items")
)
View Source
var Config struct {
	Transformers map[string]tx `json:"transformers"`
}

Config stores the global config for the commands.

Currently just stores the names transformers.

View Source
var ErrInvalidCacheDirPerms = errors.New("cert cache directory must only be readable by the server user")
View Source
var ErrRemoveItems = errors.New("exactly one of --items or --path or --set must be provided")
View Source
var ErrTrashAdminOnly = errors.New("trash is only available to the server admin user")
View Source
var ErrTrashAllExpired = errors.New("--all-expired does not take any other flags")
View Source
var ErrTrashItems = errors.New("exactly one of --items, --path or --expired must be provided")
View Source
var ErrTrashName = errors.New("exactly one of --name or --all-expired must be provided")
View Source
var ErrTrashRemove = errors.New("you must provide --remove")
View Source
var RootCmd = &cobra.Command{
	Use:   "ibackup",
	Short: "ibackup backs up local files to iRODS",
	Long: `ibackup backs up local files to iRODS.

For automated backups via an ibackup server, use the add and status
sub-commands, eg.:

echo /abs/path/to/file1.txt > files.txt
echo /abs/path/to/file2.txt >> files.txt
echo /abs/path/to/dir1 > dirs.txt
echo /abs/path/to/dir2 >> dirs.txt
ibackup add -n myfirstbackup -t 'humgen' -f files.txt -d dirs.txt
ibackup status

(You'll need the ` + serverURLEnvKey + ` and ` + serverCertEnvKey + ` environment
variables set up for you by whoever started the server.)

The ` + ConfigKey + ` environmental variable can be set to specify an ibackup
configuration file.

Currently that config file is used to register named transformers. The format of
the file is as follows:

{
	"transformers": {
		"transformer1": {
			"description": "This is my first transformer",
			"re": "^/some/local/path/([^/]+)/files",
			"replace: "/remote/path/files/$1/"
		},
		"transformer2": {
			"description": "This is my second transformer",
			"re": "^/some/other/path/([^/]+)/version_([0-9]+)/",
			"replace: "/remote/path/version_$2/$1/"
		},
		…
	}
}

For manual backups, use the addremote and put sub-commands, eg. to backup
everything in a directory:

find /abs/path/to/dir -type f -print0 | ibackup addremote --humgen -0 -b | ibackup put -b
`,
}

RootCmd represents the base command when called without any subcommands.

View Source
var Version string

Version gets set during build: go build -ldflags "-X github.com/wtsi-hgi/ibackup/cmd.Version=`git describe --tags --always --long --dirty`" .

Functions

func CheckOrCreateCacheDir added in v1.14.0

func CheckOrCreateCacheDir(dir string) error

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func LoadConfig added in v1.13.0

func LoadConfig(path string) error

LoadConfig loads global config from the given path.

func ResetFlagsForTests added in v1.14.0

func ResetFlagsForTests()

ResetFlagsForTests resets all flags to their default values.

func SetCLIWriter added in v1.14.0

func SetCLIWriter(out io.Writer)

SetCLIWriter allows tests to capture CLI output.

func SetExitFunc added in v1.14.0

func SetExitFunc(fn func(int)) func(int)

SetExitFunc allows tests to intercept os.Exit.

func SetLoggerHandler added in v1.14.0

func SetLoggerHandler(handler log15.Handler)

SetLoggerHandler allows tests to override logging output.

func SetWatchCtxFunc added in v1.16.0

func SetWatchCtxFunc(
	fn func() (context.Context, context.CancelFunc),
)

SetWatchCtxFunc overrides the context factory for testing. Pass nil to restore the default.

func ValidateQueuesForTests added in v1.14.0

func ValidateQueuesForTests(useQueues string, avoidQueues string, debug bool, readOnly bool) (bool, error)

ValidateQueuesForTests exposes queue validation for test helpers.

Types

type InvalidMonitorDurationError added in v1.11.0

type InvalidMonitorDurationError struct {
	Err error
}

func (*InvalidMonitorDurationError) Error added in v1.11.0

type MonitorDurationTooShortError added in v1.11.0

type MonitorDurationTooShortError struct {
	Duration    time.Duration
	MinDuration time.Duration
}

func (*MonitorDurationTooShortError) Error added in v1.11.0

Jump to

Keyboard shortcuts

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