Documentation ¶
Index ¶
- Constants
- func PrintHelp()
- type BackupEntry
- type BackupEnv
- func (e *BackupEnv) BackupOplogToDir(cursor *mgo.Iter, dir string) (error, float32, bson.MongoTimestamp, bson.MongoTimestamp)
- func (e *BackupEnv) CleanupBackupEnv()
- func (e *BackupEnv) CopyDir(source string, dest string) (err error, backedByte int64)
- func (e *BackupEnv) CopyFile(source string, dest string) (err error, backedByte int64)
- func (e *BackupEnv) DeleteEntries(criteria, kind string) error
- func (e *BackupEnv) DeleteEntry(id string) error
- func (e *BackupEnv) DumpOplogsToDir(from, to *BackupEntry) error
- func (e *BackupEnv) GetDirSize(source string) int64
- func (e *BackupEnv) List(kind string)
- func (e *BackupEnv) PerformBackup()
- func (e *BackupEnv) PerformDeletion() error
- func (e *BackupEnv) PerformRestore()
- func (e *BackupEnv) RestoreCopyDir(entry *BackupEntry, source string, dest string, restoredByte int64, ...) (error, int64)
- func (e *BackupEnv) RestoreCopyFile(source string, dest string, entry *BackupEntry) (error, int64)
- func (e *BackupEnv) SetupBackupEnvironment(o Options) error
- type BackupHistoryFile
- func (b *BackupHistoryFile) AddNewEntry(in BackupEntry) error
- func (b *BackupHistoryFile) CheckIncrementalConsistency(entry *BackupEntry) error
- func (b *BackupHistoryFile) Create(writer *os.File) error
- func (b *BackupHistoryFile) FindEntries(criteria, kind string) (error, []BackupEntry)
- func (b *BackupHistoryFile) FindEntriesFromCriteria(criteria string, input []BackupEntry) (error, []BackupEntry)
- func (b *BackupHistoryFile) FindEntriesFromKind(kind string, input []BackupEntry) (error, []BackupEntry)
- func (b *BackupHistoryFile) Flush() error
- func (b *BackupHistoryFile) GetBackupEntry(id string) *BackupEntry
- func (b *BackupHistoryFile) GetIncEntriesBetween(from, to *BackupEntry) []BackupEntry
- func (b *BackupHistoryFile) GetLastEntryAfter(ts time.Time) *BackupEntry
- func (b *BackupHistoryFile) GetLastFullBackup(etr BackupEntry) *BackupEntry
- func (b *BackupHistoryFile) GetNextBackup(etr BackupEntry) BackupEntry
- func (b *BackupHistoryFile) Read(reader *os.File) error
- func (b *BackupHistoryFile) RemoveEntry(rm BackupEntry) error
- type HomeLog
- type Options
Constants ¶
const ( HomeFileVersion = "0.0.1" SuffixInc = '+' SuffixDec = '-' )
const ( OPLOG_DIR = "oplog/" OPLOG_FILE = "oplog.bson" )
const ( OpBackup = 0 OpRestore = 1 OpList = 4 OpDelete = 8 DefaultKind = "backup" DefaultDir = "mongo-backup" )
const (
LockFileName = "backup.lock"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackupEntry ¶
type BackupEntry struct { Id string `json:"id"` Ts time.Time `json:"ts"` Source string `json:"source"` Dest string `json:"dest"` Kind string `json:"kind"` Type string `json:"type"` Compress bool `json:"compress"` FirstOplog bson.MongoTimestamp `json:"firstOplog"` LastOplog bson.MongoTimestamp `json:"lastOplog"` }
Home file backup entry json representation
type BackupEnv ¶
type BackupEnv struct { // represent command line option Options Options // contains filtered or unexported fields }
global variable containing options & context informations
func (*BackupEnv) BackupOplogToDir ¶
func (e *BackupEnv) BackupOplogToDir(cursor *mgo.Iter, dir string) (error, float32, bson.MongoTimestamp, bson.MongoTimestamp)
dump the cursor to a directory if compress option is specified, use lz4 while dumping return the error if any, the number of byte restored, the first & last oplog dumped
func (*BackupEnv) CleanupBackupEnv ¶
func (e *BackupEnv) CleanupBackupEnv()
cleanup the environment variable in case of failover
func (*BackupEnv) CopyFile ¶
Copy a file to another destination if the compress flag is present, compress the file while copying using lz4
func (*BackupEnv) DeleteEntries ¶
Remove & delete a range of backups
func (*BackupEnv) DeleteEntry ¶
Remove & delete a specific backup
func (*BackupEnv) DumpOplogsToDir ¶
func (e *BackupEnv) DumpOplogsToDir(from, to *BackupEntry) error
dump the oplog between the entries to the requested output directory
func (*BackupEnv) GetDirSize ¶
Return the total size of the directory in byte
func (*BackupEnv) PerformBackup ¶
func (e *BackupEnv) PerformBackup()
perform an incremental or full backup check the documentation of the performFullBackup, perforIncrementalBackup for more information
func (*BackupEnv) PerformDeletion ¶
Perform deletion according to the command line options
func (*BackupEnv) PerformRestore ¶
func (e *BackupEnv) PerformRestore()
perform the restore & dump the oplog if required oplog is not automatically replayed (futur impprovment?) to restore incremental backup or point in time, mongorestore has to be used
func (*BackupEnv) RestoreCopyDir ¶
func (e *BackupEnv) RestoreCopyDir(entry *BackupEntry, source string, dest string, restoredByte int64, totalRestored int64, pb *utils.ProgressBar) (error, int64)
restore & uncompress a backup to a specific location
func (*BackupEnv) RestoreCopyFile ¶
Copy & Uncompress a specific file if required
func (*BackupEnv) SetupBackupEnvironment ¶
initialize the environment object
type BackupHistoryFile ¶
type BackupHistoryFile struct {
// contains filtered or unexported fields
}
Represent a home file
func (*BackupHistoryFile) AddNewEntry ¶
func (b *BackupHistoryFile) AddNewEntry(in BackupEntry) error
add a new entry and flush it to disk
func (*BackupHistoryFile) CheckIncrementalConsistency ¶
func (b *BackupHistoryFile) CheckIncrementalConsistency(entry *BackupEntry) error
check that that incremental restoration of this backup will be consistent
func (*BackupHistoryFile) Create ¶
func (b *BackupHistoryFile) Create(writer *os.File) error
create a new homelogfile and write it to the disk
func (*BackupHistoryFile) FindEntries ¶
func (b *BackupHistoryFile) FindEntries(criteria, kind string) (error, []BackupEntry)
return entries according to a criteria (string0 TODO should we use a lexer/parser?
func (*BackupHistoryFile) FindEntriesFromCriteria ¶
func (b *BackupHistoryFile) FindEntriesFromCriteria(criteria string, input []BackupEntry) (error, []BackupEntry)
Find entries according to a criteria
func (*BackupHistoryFile) FindEntriesFromKind ¶
func (b *BackupHistoryFile) FindEntriesFromKind(kind string, input []BackupEntry) (error, []BackupEntry)
return all entries from this kind
func (*BackupHistoryFile) Flush ¶
func (b *BackupHistoryFile) Flush() error
flush the homelogfile to disk
func (*BackupHistoryFile) GetBackupEntry ¶
func (b *BackupHistoryFile) GetBackupEntry(id string) *BackupEntry
return a backup associated to this speicifc id
func (*BackupHistoryFile) GetIncEntriesBetween ¶
func (b *BackupHistoryFile) GetIncEntriesBetween(from, to *BackupEntry) []BackupEntry
get all incremental BackupEntry between two specific entry used to realize point in time recovery and recreate the oplog
func (*BackupHistoryFile) GetLastEntryAfter ¶
func (b *BackupHistoryFile) GetLastEntryAfter(ts time.Time) *BackupEntry
get the last entry before the requested date used to determine which snapshots to recover for pit
func (*BackupHistoryFile) GetLastFullBackup ¶
func (b *BackupHistoryFile) GetLastFullBackup(etr BackupEntry) *BackupEntry
return the last full backup realized before a specific entry
func (*BackupHistoryFile) GetNextBackup ¶
func (b *BackupHistoryFile) GetNextBackup(etr BackupEntry) BackupEntry
return the next entry after the one provided
func (*BackupHistoryFile) Read ¶
func (b *BackupHistoryFile) Read(reader *os.File) error
Read & Populate the homefile structure from a file
func (*BackupHistoryFile) RemoveEntry ¶
func (b *BackupHistoryFile) RemoveEntry(rm BackupEntry) error
remove an entry and flush it to disk
type HomeLog ¶
type HomeLog struct { Version string `json:"version"` Entries []BackupEntry `json:"entries"` Sequence int `json:"seq"` }
Home file json representation
type Options ¶
type Options struct { // general options Operation int Directory string Kind string Stepdown bool Position string Debug bool // backup options Fsynclock bool Incremental bool Compress bool // mongo options Mongohost string Mongouser string Mongopwd string // restore options Output string Pit string Snapshot string }
abstract structure standing for command line options
func ParseOptions ¶
func ParseOptions() Options
parse the command line and create the Options struct