1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-08 05:57:23 +03:00

F #6029: Create Restic repo per VM (#2495)

This commit is contained in:
Michal Opala 2023-02-14 17:10:32 +01:00 committed by GitHub
parent 20f6c39a8a
commit 694ff377aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -66,6 +66,7 @@ ds_id = tokens[0].to_i
snaps = tokens[1].split(',').map {|s| s.split(':')[1] }
disk_path = tokens[2..].join('/')
disk_index = File.basename(disk_path).split('.')[1]
vm_id = disk_path.match('/(\d+)/backup/[^/]+$')[1].to_i
begin
# Do a sanity check if Restic is available/enabled.
@ -81,12 +82,11 @@ begin
rc = backup_ds.info(true)
raise StandardError, rc.message \
if OpenNebula.is_error?(backup_ds)
raise StandardError, rc.message if OpenNebula.is_error?(backup_ds)
# Pull from Restic, then post-process qcow2 disks.
rds = Restic.new backup_ds.to_xml
rds = Restic.new backup_ds.to_xml, :vm_id => vm_id
tmp_dir = "#{rds.tmp_dir}/#{SecureRandom.uuid}"
FileUtils.mkdir_p tmp_dir
@ -101,8 +101,7 @@ begin
mv '#{tmp_dir}/#{File.basename(disk_paths.last)}' '#{tmp_dir}/disk.#{disk_index}'
EOS
raise StandardError, rc.stderr \
if rc.code != 0
raise StandardError, rc.stderr if rc.code != 0
# Return shell code snippets according to the downloader's interface.

View File

@ -2940,14 +2940,13 @@ void LifeCycleManager::trigger_backup_success(int vid)
oss << "<EXTRA_DATA>"
<< "<KEEP_LAST>" << keep_last << "</KEEP_LAST>"
<< "<VM_ID>" << vid << "</VM_ID>"
<< "</EXTRA_DATA>";
if ( imagem->flatten_increments(image_id, ds_id, oss.str(), error) != 0 )
{
ostringstream oss;
oss << "backup_success, cannot flatten backup increments for image "
oss << "backup_success, cannot flatten backup increments for image "
<< image_id << " : " << error;
NebulaLog::error("LCM", oss.str());

View File

@ -78,8 +78,10 @@ module TransferManager
@increments[0] = @action.elements["#{prefix}/SOURCE"].text if @increments.empty?
# NOTE: In the case of backup images, there should always be just a single ID in the VMS array.
@vm_id = @action.elements["#{prefix}/VMS/ID"].text.to_i
@keep_last = @action.elements['/DS_DRIVER_ACTION_DATA/EXTRA_DATA/KEEP_LAST']&.text.to_i
@vm_id = @action.elements['/DS_DRIVER_ACTION_DATA/EXTRA_DATA/VM_ID']&.text.to_i
end
def last