Proxmox Unprivileged Container Backup failed, Permission denied

When trying to take a full stop backup of my LXC containers in Proxmox, I get the following error output:

INFO: starting new backup job: vzdump 107 --mode stop --compress zstd --remove 0 --node hp2 --storage truenas-nfs-hdd --notes-template ''
INFO: Starting Backup of VM 107 (lxc)
INFO: Backup started at 2022-08-20 15:12:12
INFO: status = running
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: CT Name: pihole-secondary
INFO: including mount point rootfs ('/') in backup
INFO: stopping virtual guest
INFO: creating vzdump archive '/mnt/proxmox-nfs-hdd/dump/vzdump-lxc-107-2022_08_20-15_12_12.tar.zst'
INFO: tar: /mnt/proxmox-nfs-hdd/dump/vzdump-lxc-107-2022_08_20-15_12_12.tmp: Cannot open: Permission denied
INFO: tar: Error is not recoverable: exiting now
INFO: restarting vm
INFO: guest is online again after 5 seconds
ERROR: Backup of VM 107 failed - command 'set -o pipefail && lxc-usernsexec -m u:0:100000:65536 -m g:0:100000:65536 -- tar cpf - --totals --one-file-system -p --sparse --numeric-owner --acls --xattrs '--xattrs-include=user.*' '--xattrs-include=security.capability' '--warning=no-file-ignored' '--warning=no-xattr-write' --one-file-system '--warning=no-file-ignored' '--directory=/mnt/proxmox-nfs-hdd/dump/vzdump-lxc-107-2022_08_20-15_12_12.tmp' ./etc/vzdump/pct.conf ./etc/vzdump/pct.fw '--directory=/mnt/vzsnap0' --no-anchored '--exclude=lost+found' --anchored '--exclude=./tmp/?*' '--exclude=./var/tmp/?*' '--exclude=./var/run/?*.pid' ./ | zstd --rsyncable '--threads=1' >/mnt/proxmox-nfs-hdd/dump/vzdump-lxc-107-2022_08_20-15_12_12.tar.dat' failed: exit code 2
INFO: Failed at 2022-08-20 15:12:17
INFO: Backup job finished with errors
TASK ERROR: job errors

Research

Some posts recommend setting a local temp directory in /etc/vzdump.conf for each node. While this would work, my nodes do not have a lot of local storage, and there is the potential for them to run out of space when taking backups. Additionally, I would rather not have the write cycles on the boot drives if possible.

There was another post that recommended verifying that the folders are actually writeable, and adjusting the permissions by running chmod 755 if they are not. There were no issues with the permissions set on my folders, so this is not my issue, but it may be worth checking.

The Solution

This post mentions mapping all users to root as part of the NFS configuration. Because LXC containers use linux namespaces, the user in an unprivileged container will not be root, and therefore you have to map all users. In the configuration of my NFS share on my Synology NAS, I altered the NFS-permissions squash to MAP ALL USERS TO ADMIN.


Rebooted my proxmox server and then the backup of unpriviliged LXC containers worked.

How to Backup Proxmox to a Synology NAS

1. Synology NAS Configuration

Before we configure Proxmox, we need to set up NFS permissions on our Synology NAS. This will allow Proxmox to read and write to our Synology NAS.

1.Open the Control Panel on Synology DSM and select File Services then NFS.

2. Select Enable NFS service and then Apply.

NOTE: You can leave the Maximum NFS protocol as NFSv3.

3. Select Shared Folder, then Edit the folder where you’d like your Proxmox data to be stored.

NOTE: If you aren’t sure how to create a Shared Folder, you can click this link to learn how.

4. Select NFS Permissions then Create.

5. In the NFS rule, add the IP Address of your Proxmox server. Leave the privilege as Read/Write and then select Allow users to access mounted subfolders.

6. Save everything and then log in to Proxmox.

2. Proxmox Configuration

Now that our Synology NAS has been configured, we will need to set up Proxmox to read/write from our Synology NAS. We’ll then be able to backup Proxmox to a Synology NAS.

  1. Select Datacenter then Storage.

2. Select Add then NFS.

3. At the NFS screen, create an ID, then enter the IP Address of your Synology NAS server. In the Export drop-down menu, the location of your Proxmox folder should automatically appear. In the Content drop-down, select ALL entries. You can then select Add.

4. Proxmox should now show the Synology NAS Storage that we created above.

3. Back up an Individual Virtual Machine

Now that we configured Proxmox and our Synology NAS, we can easily back up a virtual machine.

  1. Select the virtual machine you’d like to back up, then select Backup.

2. In the backup tab, select the Synology NAS storage location in the top right. This will ensure that we back up to the correct location.

3. Select Backup now in the top left corner.

4. Select your StorageMode and Compression, then select Backup and the backup will start!

3. Automatic Backups – How to Backup Proxmox to a Synology NAS

You can easily configure Automatic backups in Proxmox for all of your virtual machines if you’d like. This will automatically back up every virtual machine on a specific schedule.

  1. Select Datacenter then Backup, then select Add.

2. Select the Storage for your Synology NAS, then specify the ScheduleSelection modeCompression, and Mode.

3. You can also change the retention policy to only keep a certain number of versions by selecting the Retention tab. 
Without specifying a retention policy, all backups will be stored which will drastically reduce storage space on your Synology NAS over time.

4. Your virtual machines will now back up to your Synology NAS automatically after you select Create!

4. Restoring a Virtual Machine from a Backup

After the backups have been created, you can easily restore your virtual machine to one of them if you ever need to.

  1. Select the virtual machine, then Backup.

2. Select the Synology NAS storage in the top right under Storage.

3. Select the snapshot you’d like to restore to, then select Restore.

4. All information can stay as default, then select Restore.

5. You will receive a message that this will permanently erase the existing virtual machine. If you agree, select Yes. Your virtual machine will now be restored from the backup you selected!

5. Conclusion – How to Backup Proxmox to a Synology NAS

This tutorial shows how to backup Proxmox to a Synology NAS. Overall, this is a really good way to ensure that your virtual machines are backed up properly and automatically. This also gives you a pretty easy path to backing them up offsite using Hyper Backup if you’re interested.

Thanks so much for checking out the tutorial. If you have any questions on how to backup Proxmox to a Synology NAS, please leave them in the comment section of the YouTube video above!

Credits to Wundertech.net