diff --git a/cmd/incusd/migrate_storage_volumes.go b/cmd/incusd/migrate_storage_volumes.go index 6e7c7435b41..413e5591770 100644 --- a/cmd/incusd/migrate_storage_volumes.go +++ b/cmd/incusd/migrate_storage_volumes.go @@ -353,7 +353,7 @@ func (c *migrationSink) DoStorage(state *state.State, projectName string, poolNa for _, sourceSnap := range sourceSnapshots { sourceSnapshotComparable = append(sourceSnapshotComparable, storagePools.ComparableSnapshot{ Name: sourceSnap.GetName(), - CreationDate: time.Unix(sourceSnap.GetCreationDate(), 0), + CreationDate: time.Unix(0, sourceSnap.GetCreationDate()), }) } @@ -501,7 +501,7 @@ func volumeSnapshotToProtobuf(vol *api.StorageVolumeSnapshot) *migration.Snapsho LocalDevices: []*migration.Device{}, Architecture: proto.Int32(0), Stateful: proto.Bool(false), - CreationDate: proto.Int64(0), + CreationDate: proto.Int64(vol.CreatedAt.UnixNano()), LastUsedDate: proto.Int64(0), ExpiryDate: proto.Int64(0), } diff --git a/internal/server/storage/backend.go b/internal/server/storage/backend.go index 5a4956fa2e7..ebdb12404d3 100644 --- a/internal/server/storage/backend.go +++ b/internal/server/storage/backend.go @@ -6211,6 +6211,7 @@ func (b *backend) GenerateCustomVolumeBackupConfig(projectName string, volName s Name: snapName, // Snapshot only name, not full name. Config: dbVolSnaps[i].Config, ContentType: dbVolSnaps[i].ContentType, + CreatedAt: dbVolSnaps[i].CreationDate, } config.VolumeSnapshots = append(config.VolumeSnapshots, &snapshot) diff --git a/test/suites/storage_local_volume_handling.sh b/test/suites/storage_local_volume_handling.sh index b9c4c9eafd2..3370f1ba672 100644 --- a/test/suites/storage_local_volume_handling.sh +++ b/test/suites/storage_local_volume_handling.sh @@ -219,20 +219,8 @@ test_storage_local_volume_handling() { incus storage volume snapshot create "${source_pool}" vol5 incus storage volume set "${source_pool}" vol5 user.foo=snap1vol5 incus storage volume snapshot create "${source_pool}" vol5 - incus storage volume set "${source_pool}" vol5 user.foo=snapremovevol5 - incus storage volume snapshot create "${source_pool}" vol5 snapremove incus storage volume set "${source_pool}" vol5 user.foo=postsnap1vol5 - # create storage volume with user config differing over snapshots and additional snapshot than vol5 - incus storage volume create "${source_pool}" vol6 --type=block size=4194304 - incus storage volume set "${source_pool}" vol6 user.foo=snap0vol6 - incus storage volume snapshot create "${source_pool}" vol6 - incus storage volume set "${source_pool}" vol6 user.foo=snap1vol6 - incus storage volume snapshot create "${source_pool}" vol6 - incus storage volume set "${source_pool}" vol6 user.foo=snap2vol6 - incus storage volume snapshot create "${source_pool}" vol6 - incus storage volume set "${source_pool}" vol6 user.foo=postsnap1vol6 - # copy to new volume destination with refresh flag incus storage volume copy --refresh "${source_pool}/vol5" "${target_pool}/vol5" @@ -240,19 +228,23 @@ test_storage_local_volume_handling() { incus storage volume get "${target_pool}" vol5 user.foo | grep -Fx "postsnap1vol5" incus storage volume get "${target_pool}" vol5/snap0 user.foo | grep -Fx "snap0vol5" incus storage volume get "${target_pool}" vol5/snap1 user.foo | grep -Fx "snap1vol5" - incus storage volume get "${target_pool}" vol5/snapremove user.foo | grep -Fx "snapremovevol5" + + # create additional snapshot on source_pool and one on target_pool + incus storage volume snapshot create "${source_pool}" vol5 postsnap1vol5 + incus storage volume set "${target_pool}" vol5 user.foo=snapremovevol5 + incus storage volume snapshot create "${target_pool}" vol5 snapremove # incremental copy to existing volume destination with refresh flag - incus storage volume copy --refresh "${source_pool}/vol6" "${target_pool}/vol5" + incus storage volume copy --refresh "${source_pool}/vol5" "${target_pool}/vol5" # check snapshot volumes (including config) was overridden from new source and that missing snapshot is # present and that the missing snapshot has been removed. - # Note: Due to a known issue we are currently only diffing the snapshots by name, so infact existing - # snapshots of the same name won't be overwritten even if their config or contents is different. - incus storage volume get "${target_pool}" vol5 user.foo | grep -Fx "postsnap1vol5" + # Note: We are currently diffing the snapshots by name and creation date, so infact existing + # snapshots of the same name and cretion date won't be overwritten even if their config or contents is different. + incus storage volume get "${target_pool}" vol5 user.foo | grep -Fx "snapremovevol5" incus storage volume get "${target_pool}" vol5/snap0 user.foo | grep -Fx "snap0vol5" incus storage volume get "${target_pool}" vol5/snap1 user.foo | grep -Fx "snap1vol5" - incus storage volume get "${target_pool}" vol5/snap2 user.foo | grep -Fx "snap2vol6" + incus storage volume get "${target_pool}" vol5/postsnap1vol5 user.foo | grep -Fx "postsnap1vol5" ! incus storage volume get "${target_pool}" vol5/snapremove user.foo || false # copy ISO custom volumes @@ -272,7 +264,6 @@ test_storage_local_volume_handling() { incus storage volume delete "${target_pool}" vol4 incus storage volume delete "${source_pool}" vol5 incus storage volume delete "${target_pool}" vol5 - incus storage volume delete "${source_pool}" vol6 incus storage volume delete "${target_pool}" iso1 incus storage volume delete "${target_pool}" iso2 rm -f foo.iso