Commit ac70c6cf by InformatiQ Committed by Daniel Lezcano

if after freezing the container the snapshot/rsync fails, unfreeze before exiting

parent 8534a83e
...@@ -198,10 +198,15 @@ if [ -b $oldroot ]; then ...@@ -198,10 +198,15 @@ if [ -b $oldroot ]; then
if [ $container_running == "True" ]; then if [ $container_running == "True" ]; then
lxc-freeze -n $lxc_orig lxc-freeze -n $lxc_orig
fi fi
lvcreate -s -L $lxc_size -n ${lxc_lv_prefix}${lxc_new}_snapshot $oldroot || exit 1 lvcreate -s -L $lxc_size -n ${lxc_lv_prefix}${lxc_new}_snapshot $oldroot
RETVAL=$?
if [ $container_running == "True" ]; then if [ $container_running == "True" ]; then
lxc-unfreeze -n $lxc_orig lxc-unfreeze -n $lxc_orig
fi fi
if [ $RETVAL -ne 0 ]; then
echo "snapshot creation failed"
exit 1
fi
if [ $snapshot == "no" ]; then if [ $snapshot == "no" ]; then
#mount snapshot #mount snapshot
mkdir -p ${rootfs}_snapshot mkdir -p ${rootfs}_snapshot
...@@ -231,10 +236,15 @@ else ...@@ -231,10 +236,15 @@ else
if [ $container_running == True ];then if [ $container_running == True ];then
lxc-freeze -n $lxc_orig lxc-freeze -n $lxc_orig
fi fi
rsync -ax $lxc_path/$lxc_orig/rootfs $lxc_path/$lxc_new/rootfs || return 1 rsync -ax $lxc_path/$lxc_orig/rootfs $lxc_path/$lxc_new/rootfs
RETVAL=$?
if [ $container_running == True ];then if [ $container_running == True ];then
lxc-unfreeze -n $lxc_orig lxc-unfreeze -n $lxc_orig
fi fi
if [ RETVAL -ne 0 ]; then
echo "copying rootfs failed"
exit 1
fi
echo "lxc.rootfs = $rootfs" >> $lxc_path/$lxc_new/config echo "lxc.rootfs = $rootfs" >> $lxc_path/$lxc_new/config
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment