TASK ERROR: unable to restore CT - Template feature is not available

Paganini

New Member
Mar 27, 2021
5
0
1
32
Hello there. I'm trying to create a new ct from a backup file (Ubuntu 20.04) and keep receiving the following error:

Code:
TASK ERROR: unable to restore CT 100 - Template feature is not available for '/mnt/NETWORKDRIVE'

I'm unsure of how to continue from here.

Thanks.
 
Last edited:
Here's something I've tried:

I extracted the backup and edited the pct.conf file to no longer include mp0 and mp1. When I re-tar and try to restore it, the config file cannot be found. Perhaps I'm doing this wrong? I'm also not sure if this would solve the issue as I cannot find much information on the error I'm experiencing.
 
Hi,
the backup was taken from a container template, so when restoring PVE tries to convert it to a template again. Try restoring it on a storage which supports templates. What kind of storage is configured for /mnt/NETWORKDRIVE?
 
Hi,
the backup was taken from a container template, so when restoring PVE tries to convert it to a template again. Try restoring it on a storage which supports templates. What kind of storage is configured for /mnt/NETWORKDRIVE?
Yes, that does sound right.

What do you mean by a storage that supports templates?

/mnt/NETWORKDRIVE is a network drive mounted on the machine. When the container was running two folders from the network drive were attached via mountpoints.
 
Sorry, I was reading the error message wrong. For some storages (e.g. LVM) PVE doesn't support converting to template, but that's not the problem here. It seems like we do allow adding bind mounts after converting a container and then the restore doesn't work anymore...

I created a bug entry, but until that is fixed, you were already on the right track for a workaround:

If you have any experience with vim, you can simply edit the tar file and you should see the list of contents. Then you can move your cursor to the /etc/vzdump.conf click Enter and edit the file normally.

Otherwise you can first get the configuration file and edit it (easiest is to remove the template: 1 line) and call it pct.conf. Then in the directory with the backup file do:
Code:
# delete the old file in the archive
tar --delete -f vzdump-lxc-104-2021_03_30-09_37_07.tar ./etc/vzdump/pct.conf

# prepare the file
mkdir -p ./etc/vzdump
mv pct.conf ./etc/vzdump

# add the new file to the archive
tar -uf vzdump-lxc-104-2021_03_30-09_37_07.tar ./etc/vzdump/pct.conf

Afterwards restoring should work.
 
Sorry, I was reading the error message wrong. For some storages (e.g. LVM) PVE doesn't support converting to template, but that's not the problem here. It seems like we do allow adding bind mounts after converting a container and then the restore doesn't work anymore...

I created a bug entry, but until that is fixed, you were already on the right track for a workaround:

If you have any experience with vim, you can simply edit the tar file and you should see the list of contents. Then you can move your cursor to the /etc/vzdump.conf click Enter and edit the file normally.

Otherwise you can first get the configuration file and edit it (easiest is to remove the template: 1 line) and call it pct.conf. Then in the directory with the backup file do:
Code:
# delete the old file in the archive
tar --delete -f vzdump-lxc-104-2021_03_30-09_37_07.tar ./etc/vzdump/pct.conf

# prepare the file
mkdir -p ./etc/vzdump
mv pct.conf ./etc/vzdump

# add the new file to the archive
tar -uf vzdump-lxc-104-2021_03_30-09_37_07.tar ./etc/vzdump/pct.conf

Afterwards restoring should work.
I was hoping this would be a quick fix, but it seems I'm now running into new issues.

When I go to edit the file with vim, it tells me it cannot write and when I exit the file the tar file is reduced to 540KiB. Clearly not right.

The same happens when using the commands you provided. When I run
Code:
tar --delete
this gets printed:
Code:
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Deleting non-header from archive
tar: Exiting with failure status due to previous errors
then the file gets reduced to 540KiB and no longer works.

I have a feeling this may be related to the very large file size of the backup (12.46 GiB lzopd, 19 GiB decompressed), though I am not sure. Any suggestions?
 
Not sure why the editing doesn't work for you..

Here is a preliminary patch:
Code:
cat template_bind_mount_restore.patch
Code:
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index bae236b..f0edc45 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1187,6 +1187,8 @@ sub template_create {
     PVE::LXC::Config->foreach_volume($conf, sub {
        my ($ms, $mountpoint) = @_;
 
+       return if $mountpoint->{type} eq 'bind';
+
        my $volid = $mountpoint->{volume};
 
        die "Template feature is not available for '$volid'\n"
@@ -1196,6 +1198,8 @@ sub template_create {
     PVE::LXC::Config->foreach_volume($conf, sub {
        my ($ms, $mountpoint) = @_;
 
+       return if $mountpoint->{type} eq 'bind';
+
        my $volid = $mountpoint->{volume};
 
        PVE::Storage::activate_volumes($storecfg, [$volid]);
-- 
2.20.1
to skip the bind mounts when converting to a template.

Assuming pve-container: 3.3-4 is currently installed, you can apply it with:
Code:
patch /usr/share/perl5/PVE/LXC.pm template_bind_mount_restore.patch
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!