Documentation ¶
Overview ¶
Package fs_snapshot provides the ability to take filesystem snapshots. For now, only Windows is supported.
Index ¶
- Constants
- Variables
- func CurrentUserCanCreateSnapshots(infoCb InfoMessageCallback) (bool, error)
- func EnableSnapshotsForUser(username string, infoCb InfoMessageCallback) error
- func StartServer(snapshoter Snapshoter, cfg *ServerConfig) error
- type BackupConfig
- type Backuper
- type ConnectionType
- type InfoMessageCallback
- type MessageLevel
- type Provider
- type ServerConfig
- type Snapshot
- type SnapshotSet
- type Snapshoter
- type SnapshoterConfig
Constants ¶
View Source
const ( StatePending mountPointState = iota StateSuccess StateFailed )
View Source
const ( OutputLevel = iota InfoLevel DetailsLevel TraceLevel )
View Source
const DefaultIP = "localhost"
View Source
const DefaultPort = 33721
Variables ¶
View Source
var ErrNotSupportedInThisOS = errors.New("snapshots not supported in this OS")
View Source
var ErrSnapshotFailedInPreviousAttempt = errors.New("snapshot failed in a previous attempt")
Functions ¶
func CurrentUserCanCreateSnapshots ¶
func CurrentUserCanCreateSnapshots(infoCb InfoMessageCallback) (bool, error)
CurrentUserCanCreateSnapshots returns information if the current user can create snapshots
func EnableSnapshotsForUser ¶
func EnableSnapshotsForUser(username string, infoCb InfoMessageCallback) error
EnableSnapshotsForUser enables the current user to run snapshots. This generally must be run from a prompt with elevated privileges (root or administrator).
func StartServer ¶
func StartServer(snapshoter Snapshoter, cfg *ServerConfig) error
Types ¶
type BackupConfig ¶
type BackupConfig struct { ProviderID string Timeout time.Duration // Simple - try to do it as simple as possible, but not simpler. // In Windows this means do not use VSS Writers. Simple bool // If set, overrides the info callback from the snapshoter InfoCallback InfoMessageCallback }
type Backuper ¶
type Backuper interface { // TryToCreateTemporarySnapshot returns the snapshoted directory volume if a snapshot could be made, // or the original directory otherwise. // If the directory is not yet available as a snapshot, a snapshot is created. // If the directory is inside an existing snapshot, the snapshot is re-used. // An error is returned iff some problem occurred while creating the snapshot, but not // if the directory does not support snapshots. TryToCreateTemporarySnapshot(directory string) (string, *Snapshot, error) // Close frees all resources. Close() }
Backuper is a class that allows easy temporary snapshot creation. All snapshots created will be deleted when calling Close.
type ConnectionType ¶
type ConnectionType int
const ( LocalOrServer ConnectionType = iota LocalOnly ServerOnly )
type InfoMessageCallback ¶
type InfoMessageCallback func(level MessageLevel, format string, a ...interface{})
type MessageLevel ¶
type MessageLevel int
type ServerConfig ¶
type ServerConfig struct { // IP to listen on. Use "0.0.0.0" to listen on all interfaces. Default is "localhost". IP string // Port to listen on. Port int // InactivityTime to stop the server, if this is > 0. InactivityTime time.Duration InfoCallback InfoMessageCallback }
func (*ServerConfig) Address ¶
func (cfg *ServerConfig) Address() string
type SnapshotSet ¶
type Snapshoter ¶
type Snapshoter interface { // ListProviders list all provider available // filterID: filter by id if != "" ListProviders(filterID string) ([]*Provider, error) // ListSets list all snapshot sets available // filterID: filter by id if != "" ListSets(filterID string) ([]*SnapshotSet, error) // ListSnapshots list all snapshots available // filterID: filter by id if != "" ListSnapshots(filterID string) ([]*Snapshot, error) // SimplifyID simplifies the snapshot, set and provider IDs, if possible SimplifyID(id string) string // DeleteSet deletes one snapshot set and all its snapshots. // Returns true if snapshot was found and deleted, false if it was not found and an // error if something went wrong. DeleteSet(id string, force bool) (bool, error) // DeleteSnapshot deletes one snapshot // Returns true if snapshot was found and deleted, false if it was not found and an // error if something went wrong. DeleteSnapshot(id string, force bool) (bool, error) // ListMountPoints lists all mount points inside a volume. ListMountPoints(volume string) ([]string, error) // StartBackup creates a Backuper to allow easy backup creation. StartBackup(cfg *BackupConfig) (Backuper, error) // Close frees all resources. Close() }
func NewSnapshoter ¶
func NewSnapshoter(cfg *SnapshoterConfig) (Snapshoter, error)
NewSnapshoter creates a new snapshoter. In case of error a null snapshoter is returned, so you can use it without problem.
type SnapshoterConfig ¶
type SnapshoterConfig struct { ConnectionType ConnectionType ServerIP string ServerPort int InfoCallback InfoMessageCallback }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.