Add network class
[nitsi.git] / qcow2-copy.sh
... / ...
CommitLineData
1#!/bin/bash
2
3image=${1}
4uuid=${2}
5from=${3}
6to=${4}
7
8i=0
9
10tmp_dir=$(mktemp -d)
11
12while 1; do
13 if [ ! -f "/dev/nbd${i}"]; then
14 break
15 fi
16 i=((i + 1))
17done
18
19qemu-nbd --connect="/dev/nbd${i}" "${image}"
20
21mount UUID="${uuid}" "${tmp_dir}"
22
23cp -R -v "${from}" "${tmp_dir}${to}"
24
25if umount "${tmp_dir}"; then
26 rm -f -d "${tmp_dir}"
27fi
28
29