backup metadata are written in separate file (#560)

Signed-off-by: Alexander Marshalov <_@marshalov.org>
This commit is contained in:
Alexander Marshalov 2023-05-16 14:21:56 +02:00 committed by Aliaksandr Valialkin
parent 7b15834cbe
commit 3b2dc2b098
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 8 additions and 1 deletions

View file

@ -79,6 +79,10 @@ func (b *Backup) Run() error {
if err := storeMetadata(src, dst); err != nil {
return fmt.Errorf("cannot store backup metadata: %w", err)
}
if err := dst.CreateFile(fscommon.BackupCompleteFilename, []byte{}); err != nil {
return fmt.Errorf("cannot create `backup complete` file at %s: %w", dst, err)
}
return nil
}
@ -99,7 +103,7 @@ func storeMetadata(src *fslocal.FS, dst common.RemoteFS) error {
return fmt.Errorf("cannot marshal metadata: %w", err)
}
if err := dst.CreateFile(fscommon.BackupCompleteFilename, metadata); err != nil {
if err := dst.CreateFile(fscommon.BackupMetadataFilename, metadata); err != nil {
return fmt.Errorf("cannot create `backup complete` file at %s: %w", dst, err)
}

View file

@ -235,3 +235,6 @@ func IgnorePath(path string) bool {
// BackupCompleteFilename is a filename, which is created in the destination fs when backup is complete.
const BackupCompleteFilename = "backup_complete.ignore"
// BackupMetadataFilename is a filename, which contains metadata for the backup.
const BackupMetadataFilename = "backup_metadata.ignore"