migrate_support_for_latest_lxd_version
This commit is contained in:
parent
e2254f2fb7
commit
6bc63929c4
1 changed files with 20 additions and 1 deletions
|
@ -161,7 +161,8 @@ ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=/var/lib/lxd/storage-pools/"$DES
|
||||||
echo "Fixing config for bionic"
|
echo "Fixing config for bionic"
|
||||||
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.idmap.current/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.idmap exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.idmap.current/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.idmap exited with non-zero"; exit 1; }
|
||||||
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.uuid/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.uuid exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.uuid/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.uuid exited with non-zero"; exit 1; }
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.cloud-init.instance-id/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.cloud-init.instance-id exited with non-zero"; exit 1; }
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.last_state.ready/d' /var/lib/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.last_state.ready exited with non-zero"; exit 1; }
|
||||||
|
|
||||||
echo "Importing "$CONT_VAR" on destination"
|
echo "Importing "$CONT_VAR" on destination"
|
||||||
ssh "$DEST_IP" -p $DEST_PORT lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
||||||
|
@ -178,15 +179,33 @@ else
|
||||||
if [ -z "$SNAP_TO_SEND_FIRST_FOR_LATER_CHECK" ]
|
if [ -z "$SNAP_TO_SEND_FIRST_FOR_LATER_CHECK" ]
|
||||||
then
|
then
|
||||||
echo "Setting up mountpoint on destination for "$CONT_VAR""
|
echo "Setting up mountpoint on destination for "$CONT_VAR""
|
||||||
|
target_snap_version=$(ssh "$DEST_IP" -p $DEST_PORT snap info lxd| grep tracking: | awk {'print $2'} | cut -d"/" -f-1 | cut -d"." -f-1)
|
||||||
|
if [[ "$target_snap_version" == 4 ]]
|
||||||
|
then
|
||||||
ssh "$DEST_IP" -p $DEST_PORT zfs set canmount=noauto "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT zfs set canmount=noauto "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
||||||
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=/var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=/var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR" "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
||||||
ssh "$DEST_IP" -p $DEST_PORT zfs mount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT zfs mount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint on destination exited with non-zero"; exit 1; }
|
||||||
REMOTE_LXD_PID=$(ssh "$DEST_IP" -p $DEST_PORT cat /var/snap/lxd/common/lxd.pid); (($? != 0)) && { echo "SSH command to get REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
|
REMOTE_LXD_PID=$(ssh "$DEST_IP" -p $DEST_PORT cat /var/snap/lxd/common/lxd.pid); (($? != 0)) && { echo "SSH command to get REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
|
||||||
ssh "$DEST_IP" -p $DEST_PORT "nsenter -t $REMOTE_LXD_PID -m bash -c \"mount -t zfs "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"\""; (($? != 0)) && { echo "SSH command to set REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT "nsenter -t $REMOTE_LXD_PID -m bash -c \"mount -t zfs "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"\""; (($? != 0)) && { echo "SSH command to set REMOTE_LXD_PID on destination exited with non-zero"; exit 1; }
|
||||||
|
|
||||||
|
echo "Fixing config for lxd version 4"
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.cloud-init.instance-id/d' /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.cloud-init.instance-id exited with non-zero"; exit 1; }
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT sed -i '/volatile.last_state.ready/d' /var/snap/lxd/common/lxd/storage-pools/"$DEST_ZPOOL_2"/containers/"$CONT_VAR"/backup.yaml; (($? != 0)) && { echo "SSH command to setup volatile.last_state.ready exited with non-zero"; exit 1; }
|
||||||
|
|
||||||
echo "Importing "$CONT_VAR" on destination"
|
echo "Importing "$CONT_VAR" on destination"
|
||||||
ssh "$DEST_IP" -p $DEST_PORT /snap/bin/lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT /snap/bin/lxd import "$CONT_VAR" --force; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
||||||
ssh "$DEST_IP" -p $DEST_PORT zfs umount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
ssh "$DEST_IP" -p $DEST_PORT zfs umount "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to import container exited with non-zero"; exit 1; }
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "Doing lxd recover"
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT zfs set mountpoint=legacy "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"; (($? != 0)) && { echo "SSH command to setup mountpoint=legacy on destination exited with non-zero"; exit 1; }
|
||||||
|
ssh "$DEST_IP" -p $DEST_PORT "cat <<EOF | lxd recover
|
||||||
|
no
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
EOF"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting "$CONT_VAR" on destination"
|
echo "Starting "$CONT_VAR" on destination"
|
||||||
|
|
Loading…
Reference in a new issue