pct push when LXC is offline

apmuthu

Renowned Member
Feb 26, 2009
868
11
83
Chennai - India & Singapore
github.com
Code:
pct push <VMID>
pct pull <VMID>
The above can be used on the host only when the LXC container is started and running with say pct start 101.

When an LXC has been created, pct set hostscript ... can be used to execute a script on the LXC guest when it is started or when it is explicitly stopped from a running state but not from a stopped state.

Executing the following on the host will put in a file and set it the correct permissions and ownerships (taken from within the container) into an LXC guest even when it is in stopped / unbootable state.
Bash:
#! /bin/bash

curdir=`pwd`;
node=`hostname`;
vmid="${1}"; # taken from the first argument
# vmid=101; # hardcoded
mntdir=`pct mount $vmid | cut -d"'" -f2`;
echo "$vmid $node" > $mntdir/root/vmid_node.txt;
owner=`ls -l  $mntdir | tail -n+2 | head -n1 | cut -d" " -f4`;
chown ${owner}:${owner} $mntdir/root/vmid_node.txt;
pct unmount $vmid;
cd $curdir;

Usage when the above is in say send_vmid.sh, a 755 file on the host: ./send_vmid.sh 101

This should be tweaked by checking that the container is of type lxc (taken from /etc/appliance.info file in the LXC guest filesystem) before performing this task.
 

Attachments

Last edited:

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!