Try to preserve sparse files when dumping with no compression

Implemented by Thomas Wagner <wagner-thomas@gmx.at>
tags/virt-backup-0.2.24-1
Daniel Berteaud 5 years ago
parent 0137f980e6
commit 0637c9320e
  1. 12
      virt-backup

@ -584,8 +584,16 @@ sub run_dump{
$cmd .= " | $dumpcmd 2>/dev/null";
}
else {
print "\nStarting dump of $source to $dest\n\n" if ($opts{debug});
$cmd = "$opts{ionice} dd if=$source bs=$opts{blocksize} | $opts{nice} $opts{compcmd} > $dest 2>/dev/null";
if ( -f $source && $opts{compcmd} eq 'cat' ){
# Source disk is a regular file and no compression was selected
# thus use cp instead of dd to preserve possible sparsity
print "\nStarting dump of $source to $dest using cp -a\n\n" if ($opts{debug});
$cmd = "$opts{ionice} cp -a $source $dest";
}
else {
print "\nStarting dump of $source to $dest using dd\n\n" if ($opts{debug});
$cmd = "$opts{ionice} dd if=$source bs=$opts{blocksize} | $opts{nice} $opts{compcmd} > $dest 2>/dev/null";
}
}
}
unless( system("$cmd") == 0 ){

Loading…
Cancel
Save