Finally! Taking a snapshot of an LXC container with bind mounts is solved

a computer with a white screen sitting on a table

by

Summary

  • No built-in UI for scheduled snapshots in Proxmox VE.
  • You cannot take snapshots of LXC containers with bind mounts attached.
  • The method for unmounting bind mounts from the host is poorly documented.
  • Google and AI sites are generally unaware of the correct documentation or command for this.
  • The solution is a CLI command: pct set <CTID> -delete mpX (e.g., pct set 110 -delete mp0).

The Problem: Snapshots with Bind Mounts

Snapshots are a powerful feature in Proxmox LXC, allowing you to capture and restore an OS’s state instantly. However, a significant limitation arises when you have bind mounts attached to an LXC container: you cannot take a snapshot. For the past year, I’ve struggled to achieve this functionality via CLI scripts, primarily due to misleading information from search engines and AI tools.

As of July 24, 2025, if you search for “unmount LXC bindmount” or “remove LXC bindmount” you’re typically directed towards the umount command or modifying configuration files directly on the host. Neither of these is an ideal solution for temporary unmounting to create snapshots. Even latest AI models like ChatGPT, Perplexity, and Gemini provide similar unhelpful advice.

Here’s an example of such a response from Gemini: https://g.co/gemini/share/19b527cf2506

Prompt

The Solution: pct set -delete

It wasn’t until last week that I stumbled upon a Reddit post which revealed the correct command: https://forum.proxmox.com/threads/how-to-remove-bind-mount-using-cli.130210

The command to remove a bind mount is:
pct set <CTID> -delete mpX (where X is the mount point index, e.g., mp0, mp1).

Finally! Here is script to automate snapshot with bindmount handling

Here’s a sample script to automate the process of taking a snapshot, including the removal and restoration of bind mounts:

#!/usr/bin/env bash

# Define the container ID
CTID="2012"

# Define the snapshot name
SNAPSHOT_NAME="Snapshot-$(date +%Y-%m-%d_%H-%M-%S)"

echo "Taking snapshot '$SNAPSHOT_NAME' for container $CTID..."

# Shutdown LXC
echo "Shutting down LXC $CTID..."
pct shutdown $CTID

# Wait for shutdown
echo "Waiting for container to stop..."
while pct status $CTID | grep -q "running"; do
  echo "Container $CTID is still running. Waiting..."
  sleep 5
done

echo "Container $CTID has stopped."

# Remove bindmounts
echo "Removing bindmount points..."
# Adjust mpX as per your container's bind mounts
pct set $CTID -delete mp1
pct set $CTID -delete mp2

# Take Snapshot
echo "Taking snapshot '$SNAPSHOT_NAME' for container $CTID..."
pct snapshot $CTID "$SNAPSHOT_NAME"

# Restore bindmounts
echo "Restoring previous mounts..."

echo "Mounting: -mp1 /mnt/bindmounts/tank,mp=/data"
pct set $CTID -mp1 /mnt/bindmounts/tank,mp=/data

echo "Mounting: -mp2 /mnt/pve/storage,mp=/storage"
pct set $CTID -mp2 /mnt/pve/storage,mp=/storage

# Start the LXC container
echo "Starting container $CTID..."
pct start $CTID

echo "Snapshot process completed for container $CTID."

References

References