Documentation
¶
Index ¶
- Constants
- Variables
- func BuildBackupPlan(ctx context.Context, lg logger.PackageLog, config *Config, notifier Notifier) (*BackupPlan, *Progress, error)
- func ChipherStr(str string) string
- func CreateMetadataSignatureFile(config *Config, destPath string) error
- func EncodeSignatures(signs NodeSignatures) (string, error)
- func GetBackupFolderName(incomplete bool, date *time.Time) string
- func GetBackupTypeDescription(backupType core.FolderBackupType) string
- func GetLogFileName() string
- func GetMetadataSignatureFileName() string
- func GetRsyncLogFileName() string
- func MeasureDir(ctx context.Context, dir *core.Dir, retryCount *int, log *rsync.Logging, ...) (int, error)
- type BackupNode
- type BackupNodePlan
- type BackupPlan
- type Config
- type FilesSortedByDate
- type LogFiles
- type NodeSignature
- type NodeSignatures
- type Notifier
- type PrevBackup
- type PrevBackups
- type Progress
- func (this *Progress) CalcTimePassedAndETA(plan *BackupPlan) (time.Duration, *time.Duration)
- func (this *Progress) Close() error
- func (this *Progress) EventBackupStage_FolderDoneBackup(paths core.SrcDstPath, backupType core.FolderBackupType, plan *BackupPlan, ...) error
- func (this *Progress) EventBackupStage_FolderStartBackup(paths core.SrcDstPath, backupType core.FolderBackupType, plan *BackupPlan) error
- func (this *Progress) EventPlanStage_NodeStructureDoneInquiry(sourceId int, sourceRsync string, dir *core.Dir) error
- func (this *Progress) EventPlanStage_NodeStructureStartInquiry(sourceId int, sourceRsync string) error
- func (this *Progress) FinishBackupStage()
- func (this *Progress) FinishPlanStage()
- func (this *Progress) GetBackupFullPath(backupFolder string) string
- func (this *Progress) GetTotalStatistics(plan *BackupPlan) ([]string, error)
- func (this *Progress) GetTotalTimeTaken() time.Duration
- func (this *Progress) LeftToBackup(plan *BackupPlan) core.FolderSize
- func (this *Progress) PrevBackupsUsed(prevBackups *PrevBackups)
- func (this *Progress) PrintTotalStatistics(lg logger.PackageLog, plan *BackupPlan) error
- func (this *Progress) SayGoodbye(lg logger.PackageLog)
- func (this *Progress) SetBackupFolder(backupFolder string) error
- func (this *Progress) SetRootDestination(rootDestPath string)
- func (this *Progress) SizeBackedUp() core.FolderSize
- func (this *Progress) StartBackupStage()
- func (this *Progress) StartPlanStage()
Constants ¶
const ( MsgRsyncInfo = "RsyncInfo" MsgGolangInfo = "GolangInfo" MsgFolderBackupTypeSkipDescription = "FolderBackupTypeSkipDescription" MsgFolderBackupTypeRecursiveDescription = "FolderBackupTypeRecursiveDescription" MsgFolderBackupTypeContentDescription = "FolderBackupTypeContentDescription" MsgLogPlanStageStarting = "LogPlanStageStarting" MsgLogPlanStageStartTime = "LogPlanStageStartTime" MsgLogPlanStageEndTime = "LogPlanStageEndTime" MsgLogPlanStartIterateViaNSources = "LogPlanStartIterateViaNSources" MsgLogPlanStageInquirySource = "LogPlanStageInquirySource" MsgLogPlanStageSourceFolderCountInfo = "LogPlanStageSourceFolderCountInfo" MsgLogPlanStageSourceSkipFolderCountInfo = "LogPlanStageSourceSkipFolderCountInfo" MsgLogPlanStageSourceTotalSizeInfo = "LogPlanStageSourceTotalSizeInfo" MsgLogPlanStageUseTemporaryFolder = "LogPlanStageUseTemporaryFolder" MsgLogPlanStageBuildFolderError = "LogPlanStageBuildFolderError" MsgLogBackupStageStarting = "LogBackupStageStarting" MsgLogBackupStageStartTime = "LogBackupStageStartTime" MsgLogBackupStageEndTime = "LogBackupStageEndTime" MsgLogBackupStageBackupToDestination = "LogBackupStageBackupToDestination" MsgLogBackupStagePreviousBackupDiscoveryPermissionError = "LogBackupStagePreviousBackupDiscoveryPermissionError" MsgLogBackupStagePreviousBackupDiscoveryOtherError = "LogBackupStagePreviousBackupDiscoveryOtherError" MsgLogBackupStagePreviousBackupFoundAndWillBeUsed = "LogBackupStagePreviousBackupFoundAndWillBeUsed" MsgLogBackupStagePreviousBackupFoundButDisabled = "LogBackupStagePreviousBackupFoundButDisabled" MsgLogBackupStagePreviousBackupNotFound = "LogBackupStagePreviousBackupNotFound" MsgLogBackupStageStartToBackupFromSource = "LogBackupStageStartToBackupFromSource" MsgLogBackupStageRenameDestination = "LogBackupStageRenameDestination" MsgLogBackupStageFailedToCreateFolder = "LogBackupStageFailedToCreateFolder" MsgLogBackupDetectedTotalBackupSizeGetChanged = "LogBackupDetectedTotalBackupSizeGetChanged" MsgLogBackupStageProgressBackupSuccess = "LogBackupStageProgressBackupSuccess" MsgLogBackupStageProgressBackupError = "LogBackupStageProgressBackupError" MsgLogBackupStageProgressSkipBackupError = "LogBackupStageProgressSkipBackupError" MsgLogBackupStageCriticalError = "LogBackupStageCriticalError" MsgLogBackupStageDiscoveringPreviousBackups = "LogBackupStageDiscoveringPreviousBackups" MsgLogBackupStageRecoveredFromError = "LogBackupStageRecoveredFromError" MsgLogBackupStageSaveRsyncExtraLogTo = "LogBackupStageSaveRsyncExtraLogTo" MsgLogBackupStageSaveLogTo = "LogBackupStageSaveLogTo" MsgLogBackupStageExitMessage = "LogBackupStageExitMessage" MsgLogStatisticsSummaryCaption = "LogStatisticsSummaryCaption" MsgLogStatisticsEnvironmentCaption = "LogStatisticsEnvironmentCaption" MsgLogStatisticsResultsCaption = "LogStatisticsResultsCaption" MsgLogStatisticsStatusCaption = "LogStatisticsStatusCaption" MsgLogStatisticsStatusSuccessfullyCompleted = "LogStatisticsStatusSuccessfullyCompleted" MsgLogStatisticsStatusCompletedWithErrors = "LogStatisticsStatusCompletedWithErrors" MsgLogStatisticsPlanStageCaption = "LogStatisticsPlanStageCaption" MsgLogStatisticsPlanStageSourceToBackup = "LogStatisticsPlanStageSourceToBackup" MsgLogStatisticsPlanStageTotalSize = "LogStatisticsPlanStageTotalSize" MsgLogStatisticsPlanStageFolderCount = "LogStatisticsPlanStageFolderCount" MsgLogStatisticsPlanStageFolderSkipCount = "LogStatisticsPlanStageFolderSkipCount" MsgLogStatisticsPlanStageTimeTaken = "LogStatisticsPlanStageTimeTaken" MsgLogStatisticsBackupStageCaption = "LogStatisticsBackupStageCaption" MsgLogStatisticsBackupStageDestinationPath = "LogStatisticsBackupStageDestinationPath" MsgLogStatisticsBackupStagePreviousBackupFound = "LogStatisticsBackupStagePreviousBackupFound" MsgLogStatisticsBackupStagePreviousBackupFoundButDisabled = "LogStatisticsBackupStagePreviousBackupFoundButDisabled" MsgLogStatisticsBackupStageNoValidPreviousBackupFound = "LogStatisticsBackupStageNoValidPreviousBackupFound" MsgLogStatisticsBackupStageTotalSize = "LogStatisticsBackupStageTotalSize" MsgLogStatisticsBackupStageSkippedSize = "LogStatisticsBackupStageSkippedSize" MsgLogStatisticsBackupStageFailedToBackupSize = "LogStatisticsBackupStageFailedToBackupSize" MsgLogStatisticsBackupStageTimeTaken = "LogStatisticsBackupStageTimeTaken" )
const MaxUint = ^uint(0)
const MinInt = -MaxInt - 1
const (
TAB_RUNE = '\t'
)
Variables ¶
var ( DoubleSplitLine string = strings.Repeat("=", 100) SingleSplitLine string = strings.Repeat("-", 100) )
var LocalLog = logger.NewPackageLogger("backup",
logger.InfoLevel,
)
Functions ¶
func BuildBackupPlan ¶
func BuildBackupPlan(ctx context.Context, lg logger.PackageLog, config *Config, notifier Notifier) (*BackupPlan, *Progress, error)
func CreateMetadataSignatureFile ¶
func EncodeSignatures ¶
func EncodeSignatures(signs NodeSignatures) (string, error)
EncodeSignatures encode NodeSignatures object to self-describing binary format.
func GetBackupFolderName ¶
GetBackupFolderName return new folder name for ongoing backup process.
func GetBackupTypeDescription ¶
func GetBackupTypeDescription(backupType core.FolderBackupType) string
func GetLogFileName ¶
func GetLogFileName() string
GetLogFileName return the name of general backup process log.
func GetMetadataSignatureFileName ¶
func GetMetadataSignatureFileName() string
GetMetadataSignatureFileName return the name of specific file which describe all sources used in backup process.
Types ¶
type BackupNode ¶
type BackupNodePlan ¶
type BackupNodePlan struct {
BackupNode BackupNode
RootDir *core.Dir
}
BackupNodePlan contain information about single rsync source backup.
type BackupPlan ¶
type BackupPlan struct {
Config *Config
Nodes []BackupNodePlan
BackupSize core.FolderSize
}
BackupPlan keep all necessary information obtained from preferences and 1st backup pass to start backup process.
type Config ¶
type Config struct {
SigFileIgnoreBackup string `toml:"sig_file_ignore_backup"`
RsyncRetryCount *int `toml:"retry_count"`
AutoManageBackupBlockSize *bool `auto_manage_backup_block_size`
MaxBackupBlockSizeMb *int `toml:"max_backup_block_size_mb"`
UsePreviousBackup *bool `toml:"use_previous_backup"`
NumberOfPreviousBackupToUse *int `toml:"number_of_previous_backup_to_use"`
EnableLowLevelLogForRsync *bool `toml:"enable_low_level_log_rsync"`
EnableIntensiveLowLevelLogForRsync *bool `toml:"enable_intensive_low_level_log_rsync"`
// rsync --compress
RsyncCompressFileTransfer *bool `toml:"rsync_compress_file_transfer"`
// rsync --links
RsyncRecreateSymlinks *bool `toml:"rsync_recreate_symlinks"`
// rsync --perms
RsyncTransferSourcePermissions *bool `toml:"rsync_transfer_source_permissions"`
// rsync --group
RsyncTransferSourceGroup *bool `toml:"rsync_transfer_source_group"`
// rsync --owner
RsyncTransferSourceOwner *bool `toml:"rsync_transfer_source_owner"`
// rsync --devices
RsyncTransferDeviceFiles *bool `toml:"rsync_transfer_device_files"`
// rsync --specials
RsyncTransferSpecialFiles *bool `toml:"rsync_transfer_special_files"`
BackupNodes []BackupNode `toml:"backup_node"`
}
type FilesSortedByDate ¶
type FilesSortedByDate struct {
Files []struct {
// contains filtered or unexported fields
}
}
func (FilesSortedByDate) Len ¶
func (s FilesSortedByDate) Len() int
func (FilesSortedByDate) Less ¶
func (s FilesSortedByDate) Less(i, j int) bool
func (FilesSortedByDate) Swap ¶
func (s FilesSortedByDate) Swap(i, j int)
type LogFiles ¶
type LogFiles struct {
// contains filtered or unexported fields
}
type NodeSignature ¶
func GetSignature ¶
func GetSignature(node BackupNode) NodeSignature
type NodeSignatures ¶
type NodeSignatures struct {
Signatures []NodeSignature
}
func DecodeSignatures ¶
func DecodeSignatures(str string) (*NodeSignatures, error)
DecodeSignatures decode NodeSignatures object from self-describing binary format.
func GetNodeSignatures ¶
func GetNodeSignatures(config *Config) NodeSignatures
func (NodeSignatures) FindFirstSignature ¶
func (v NodeSignatures) FindFirstSignature(signature string) *NodeSignature
type Notifier ¶
type Notifier interface {
NotifyPlanStage_NodeStructureStartInquiry(sourceID int,
sourceRsync string) error
NotifyPlanStage_NodeStructureDoneInquiry(sourceID int,
sourceRsync string, dir *core.Dir) error
NotifyBackupStage_FolderStartBackup(rootDest string,
paths core.SrcDstPath, backupType core.FolderBackupType,
leftToBackup core.FolderSize,
timePassed time.Duration, eta *time.Duration,
) error
NotifyBackupStage_FolderDoneBackup(rootDest string,
paths core.SrcDstPath, backupType core.FolderBackupType,
leftToBackup core.FolderSize, sizeDone core.SizeProgress,
timePassed time.Duration, eta *time.Duration,
sessionErr error) error
}
type PrevBackup ¶
type PrevBackup struct {
// Full path to signature file name
SignatureFileName string
Signature NodeSignature
}
PrevBackup describe found previous backup, which contain same Rsync source. Such previous backups used for Rsync utility deduplication, which significantly decrease size and time for repeated backup sessions.
func (PrevBackup) GetDirPath ¶
func (v PrevBackup) GetDirPath() string
type PrevBackups ¶
type PrevBackups struct {
Backups []PrevBackup
}
PrevBackups keeps list of previous backup found. See description of PrevBackup.
func FindPrevBackupPathsByNodeSignatures ¶
func FindPrevBackupPathsByNodeSignatures(lg logger.PackageLog, destPath string, signs NodeSignatures, lastN int) (*PrevBackups, error)
func (*PrevBackups) GetDirPaths ¶
func (v *PrevBackups) GetDirPaths() []string
type Progress ¶
type Progress struct {
Context context.Context
LogFiles *LogFiles
Log logger.PackageLog
// LogBuffer bytes.Buffer
RsyncLog *rsync.Logging
// RsyncLogBuffer bytes.Buffer
Progress *core.SizeProgress
TotalProgress *core.SizeProgress
// GlobalErrorCount int
Notifier Notifier
StartPlanTime time.Time
EndPlanTime time.Time
StartBackupTime time.Time
EndBackupTime time.Time
PrevBackups *PrevBackups
RootDest string
BackupFolder string
// Notify only once
SizeChangedNotified bool
}
func (*Progress) CalcTimePassedAndETA ¶
func (*Progress) EventBackupStage_FolderDoneBackup ¶
func (this *Progress) EventBackupStage_FolderDoneBackup(paths core.SrcDstPath, backupType core.FolderBackupType, plan *BackupPlan, sizeDone core.SizeProgress, sessionErr error) error
func (*Progress) EventBackupStage_FolderStartBackup ¶
func (this *Progress) EventBackupStage_FolderStartBackup(paths core.SrcDstPath, backupType core.FolderBackupType, plan *BackupPlan) error
func (*Progress) EventPlanStage_NodeStructureDoneInquiry ¶
func (*Progress) EventPlanStage_NodeStructureStartInquiry ¶
func (*Progress) GetBackupFullPath ¶
func (*Progress) GetTotalStatistics ¶
func (this *Progress) GetTotalStatistics(plan *BackupPlan) ([]string, error)
func (*Progress) LeftToBackup ¶
func (this *Progress) LeftToBackup(plan *BackupPlan) core.FolderSize
func (*Progress) PrevBackupsUsed ¶
func (this *Progress) PrevBackupsUsed(prevBackups *PrevBackups)
func (*Progress) PrintTotalStatistics ¶
func (this *Progress) PrintTotalStatistics(lg logger.PackageLog, plan *BackupPlan) error
func (*Progress) SayGoodbye ¶
func (this *Progress) SayGoodbye(lg logger.PackageLog)
func (*Progress) SizeBackedUp ¶
func (this *Progress) SizeBackedUp() core.FolderSize
Source Files
¶
- abstract.go
- common.go
- config.go
- deduplication.go
- heuristic.go
- logfiles.go
- messagekeys.go
- process.go
- progress.go
- utils.go