Copy data between containers
Scripts that copy an application's data directory from one LXC container to another on the same Proxmox VE node.
The scripts in tools/copy-data/ move application data from one LXC container to another. Use them when you rebuild an application in a fresh container, or switch between two ways of running the same application, and want to keep its configuration. None of them is listed on the website.
Which script copies what
| Script | From (path in the source container) | To (path in the target container) | Target emptied first |
|---|---|---|---|
| home-assistant-container-copy-data-home-assistant-container | Home Assistant Container: /var/lib/docker/volumes/hass_config/ | Home Assistant Container: /var/lib/docker/volumes/hass_config/ | Yes |
| home-assistant-container-copy-data-home-assistant-core | Home Assistant Container: /var/lib/docker/volumes/hass_config/_data | Home Assistant Core: /root/.homeassistant | No |
| home-assistant-container-copy-data-podman-home-assistant | Home Assistant Container: /var/lib/docker/volumes/hass_config/ | Podman Home Assistant: /var/lib/containers/storage/volumes/hass_config/ | Yes |
| podman-home-assistant-copy-data-home-assistant-container | Podman Home Assistant: /var/lib/containers/storage/volumes/hass_config/ | Home Assistant Container: /var/lib/docker/volumes/hass_config/ | Yes |
| home-assistant-core-copy-data-home-assistant-container | Home Assistant Core: /root/.homeassistant | Home Assistant Container: /var/lib/docker/volumes/hass_config/_data | No |
| home-assistant-core-copy-data-home-assistant-core | Home Assistant Core: /root/.homeassistant | Home Assistant Core: /root/ | No |
| plex-copy-data-plex | Plex Media Server: /var/lib/plexmediaserver/Library/ | Plex Media Server: /var/lib/plexmediaserver/Library/ | No |
| z2m-copy-data-z2m | Zigbee2MQTT: /opt/zigbee2mqtt/data/ | Zigbee2MQTT: /opt/zigbee2mqtt/data/ | No |
| zwavejs2mqtt-copy-data-zwavejsui | Zwavejs2MQTT: /opt/zwavejs2mqtt/store/ | Z-Wave JS UI: /opt/zwave-js-ui/store/ | No |
How they work
All nine scripts follow the same pattern and run in the Proxmox VE host shell as root, not inside a container:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/copy-data/<name>.sh)"- A text prompt asks whether to proceed.
- Two radio lists ask for the source container and the target container. Both list every container on the node.
- A confirmation dialog shows
<source id> (<hostname>) -> <target id> (<hostname>). It is preselected on No. - The target container is stopped if it is running. Only the Home Assistant Core to Core script also stops the source.
- Both root disks are mounted on the host with
pct mount, and the script checks that the expected path exists in each. - Three scripts delete and recreate the target directory (see the table). The others copy into the existing directory.
rsynccopies the data with--archive --hard-links --sparse --xattrs --no-inc-recursive --info=progress2.- Both containers are unmounted again, also when the script fails.
Before you start
- Create the target container first with its regular script, so the application and its data path exist.
- Take a backup or snapshot of the target. The copy cannot be undone, and three scripts empty the target directory before copying.
- Both containers must be on the node you run the script on, and
rsyncmust be installed on the host. - Start the target container yourself afterwards; the scripts leave it stopped.
Each page lists the exact paths, the prompts and the known problems of that script. Read the limits section: on current main two scripts pass the rsync options in a form rsync does not accept, and two others place the files one directory level deeper than the target application expects.
Related
- container-restore-from-backup and core-restore-from-backup restore a Home Assistant backup archive inside a container instead of copying between two containers.
- Proxmox VE host tools for everything else that runs on the host.