doc.txt 6.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 
  2. package hybridBackup // import "imuslab.com/arozos/mod/disk/hybridBackup"
  3. FUNCTIONS
  4. func BufferedLargeFileCopy(src string, dst string, BUFFERSIZE int64) error
  5. TYPES
  6. type BackupTask struct {
  7. JobName string //The name used by the scheduler for executing this config
  8. CycleCounter int64 //The number of backup executed in the background
  9. LastCycleTime int64 //The execution time of the last cycle
  10. Enabled bool //Check if the task is enabled. Will not execute if this is set to false
  11. DiskUID string //The UID of the target fsandlr
  12. DiskPath string //The mount point for the disk
  13. ParentUID string //Parent virtal disk UUID
  14. ParentPath string //Parent disk path
  15. DeleteFileMarkers map[string]int64 //Markers for those files delete pending, [file path (relative)] time
  16. Mode string //Backup mode
  17. }
  18. func (backupConfig *BackupTask) HandleBackupProcess() (string, error)
  19. Main handler function for hybrid backup
  20. type LinkFileMap struct {
  21. UnchangedFile map[string]string
  22. DeletedFiles map[string]string
  23. }
  24. type Manager struct {
  25. Ticker *time.Ticker `json:"-"` //The main ticker
  26. StopTicker chan bool `json:"-"` //Channel for stopping the backup
  27. Tasks []*BackupTask //The backup tasks that is running under this manager
  28. }
  29. func NewHyperBackupManager() *Manager
  30. func (m *Manager) AddTask(newtask *BackupTask) error
  31. func (m *Manager) Close() error
  32. Stop all managed handlers
  33. func (m *Manager) GetParentDiskIDByRestoreDiskID(restoreDiskID string) (string, error)
  34. Get the restore parent disk ID by backup disk ID
  35. func (m *Manager) HandleRestore(restoreDiskID string, targetFileRelpath string) error
  36. Restore accidentailly removed file from backup
  37. func (m *Manager) ListRestorable(parentDiskID string) (RestorableReport, error)
  38. List the file that is restorable from the given disk
  39. func (m *Manager) StartTask(jobname string)
  40. Start a given task given name
  41. func (m *Manager) StopTask(jobname string)
  42. Stop a given task given its job name
  43. type RestorableFile struct {
  44. Filename string //Filename of this restorable object
  45. IsHidden bool //Check if the file is hidden or located in a path within hidden folder
  46. Filesize int64 //The file size to be restorable
  47. RelpathOnDisk string //Relative path of this file to the root
  48. RestorePoint string //The location this file should restore to
  49. BackupDiskUID string //The UID of disk that is hold the backup of this file
  50. RemainingTime int64 //Remaining time till auto remove
  51. DeleteTime int64 //Delete time
  52. IsSnapshot bool //Define is this restorable file point to a snapshot instead
  53. }
  54. A file in the backup drive that is restorable
  55. type RestorableReport struct {
  56. ParentUID string //The Disk ID to be restored to
  57. RestorableFiles []*RestorableFile //A list of restorable files
  58. }
  59. The restorable report
  60. type SnapshotSummary struct {
  61. ChangedFiles map[string]string
  62. UnchangedFiles map[string]string
  63. DeletedFiles map[string]string
  64. }
  65. A snapshot summary
  66. func GenerateSnapshotSummary(task *BackupTask, snapshotName string) (*SnapshotSummary, error)
  67. This function generate and return a snapshot summary