mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-02 19:54:54 -06:00
Added backup --dry-run option.
This commit is contained in:
@@ -36,6 +36,10 @@ type BackupManager struct {
|
||||
}
|
||||
|
||||
|
||||
func (manager *BackupManager) SetDryRun(dryRun bool) {
|
||||
manager.config.dryRun = dryRun
|
||||
}
|
||||
|
||||
|
||||
// CreateBackupManager creates a backup manager using the specified 'storage'. 'snapshotID' is a unique id to
|
||||
// identify snapshots created for this repository. 'top' is the top directory of the repository. 'password' is the
|
||||
@@ -630,7 +634,9 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
||||
}
|
||||
skippedFiles = append(skippedFiles, fileReader.SkippedFiles...)
|
||||
|
||||
manager.SnapshotManager.CleanSnapshotCache(localSnapshot, nil)
|
||||
if !manager.config.dryRun {
|
||||
manager.SnapshotManager.CleanSnapshotCache(localSnapshot, nil)
|
||||
}
|
||||
LOG_INFO("BACKUP_END", "Backup for %s at revision %d completed", top, localSnapshot.Revision)
|
||||
|
||||
RunAtError = func() {}
|
||||
@@ -1048,7 +1054,7 @@ func (manager *BackupManager) UploadSnapshot(chunkMaker *ChunkMaker, uploader *C
|
||||
if _, found := chunkCache[chunkID]; found {
|
||||
completionFunc(chunk, 0, true, chunk.GetLength(), 0)
|
||||
} else {
|
||||
uploader.StartChunk(chunk, len(sequence))
|
||||
uploader.StartChunk(chunk, len(sequence))
|
||||
}
|
||||
sequence = append(sequence, chunk.GetHash())
|
||||
},
|
||||
@@ -1108,8 +1114,9 @@ func (manager *BackupManager) UploadSnapshot(chunkMaker *ChunkMaker, uploader *C
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("snapshots/%s/%d", manager.snapshotID, snapshot.Revision)
|
||||
manager.SnapshotManager.UploadFile(path, path, description)
|
||||
|
||||
if !manager.config.dryRun {
|
||||
manager.SnapshotManager.UploadFile(path, path, description)
|
||||
}
|
||||
return totalSnapshotChunkSize, numberOfNewSnapshotChunks, totalUploadedSnapshotChunkSize, totalUploadedSnapshotChunkBytes
|
||||
}
|
||||
|
||||
@@ -1598,7 +1605,9 @@ func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapsho
|
||||
chunkUploader.Stop()
|
||||
|
||||
for _, snapshot := range snapshots {
|
||||
otherManager.storage.CreateDirectory(0, fmt.Sprintf("snapshots/%s", manager.snapshotID))
|
||||
if !manager.config.dryRun {
|
||||
otherManager.storage.CreateDirectory(0, fmt.Sprintf("snapshots/%s", manager.snapshotID))
|
||||
}
|
||||
description, _ := snapshot.MarshalJSON()
|
||||
path := fmt.Sprintf("snapshots/%s/%d", manager.snapshotID, snapshot.Revision)
|
||||
otherManager.SnapshotManager.UploadFile(path, path, description)
|
||||
|
||||
Reference in New Issue
Block a user