Documentation
¶
Index ¶
- Constants
- Variables
- func CheckOrCreateCacheDir(dir string) error
- func Execute()
- func LoadConfig(path string) error
- func ResetFlagsForTests()
- func SetCLIWriter(out io.Writer)
- func SetExitFunc(fn func(int)) func(int)
- func SetLoggerHandler(handler log15.Handler)
- func SetWatchCtxFunc(fn func() (context.Context, context.CancelFunc))
- func ValidateQueuesForTests(useQueues string, avoidQueues string, debug bool, readOnly bool) (bool, error)
- type InvalidMonitorDurationError
- type MonitorDurationTooShortError
Constants ¶
const (
ConfigKey = "IBACKUP_CONFIG"
)
Variables ¶
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", ) )
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") )
var Config struct { Transformers map[string]tx `json:"transformers"` }
Config stores the global config for the commands.
Currently just stores the names transformers.
var ErrInvalidCacheDirPerms = errors.New("cert cache directory must only be readable by the server user")
var ErrRemoveItems = errors.New("exactly one of --items or --path or --set must be provided")
var ErrTrashAdminOnly = errors.New("trash is only available to the server admin user")
var ErrTrashAllExpired = errors.New("--all-expired does not take any other flags")
var ErrTrashItems = errors.New("exactly one of --items, --path or --expired must be provided")
var ErrTrashName = errors.New("exactly one of --name or --all-expired must be provided")
var ErrTrashRemove = errors.New("you must provide --remove")
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.
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 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
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
SetCLIWriter allows tests to capture CLI output.
func SetExitFunc ¶ added in v1.14.0
SetExitFunc allows tests to intercept os.Exit.
func SetLoggerHandler ¶ added in v1.14.0
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.
Types ¶
type InvalidMonitorDurationError ¶ added in v1.11.0
type InvalidMonitorDurationError struct {
Err error
}
func (*InvalidMonitorDurationError) Error ¶ added in v1.11.0
func (e *InvalidMonitorDurationError) Error() string
type MonitorDurationTooShortError ¶ added in v1.11.0
func (*MonitorDurationTooShortError) Error ¶ added in v1.11.0
func (e *MonitorDurationTooShortError) Error() string