PDA

View Full Version : Migrate OpenVZ 6 VPS's into LXC on a Proxmox server



Fli
08-05-2017, 04:51 PM
Here is what apparently worked (maybe not 100% bug free), but seems good way:

ON OPENVZ SERVER

0. setup password-less access from source to destination server: ssh-copy-id destinationserverip

1. On the OpenVZ 6 host node, execute vzdump (https://openvz.org/Backup_of_a_running_container_with_vzdump) to create vzdump-CTID.tgz file out of a running VPS
I used this command:

/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/sbin/vzdump --tmpdir / --exclude-path '.+/+.tar.gz' --exclude-path '.+/log/messages.+' --exclude-path '.+/log/exim.+' --exclude-path '.+/log/maillog.+' --exclude-path '.+/log/secure.+' --exclude-path '.+/log/cron.+' --exclude-path '.+/bak/.+' --exclude-path '/tmp/.+' --exclude-path '/var/tmp/.+' --exclude-path '/var/run/.+pid' --snapshot --dumpdir=/ --compress CTIDHERE

2. move the dump to destination Proxmox server: scp /vzdump-CTIDHERE.tgz DestinationServerIP:/

ON PROXMOX SERVER

3. go to destination Proxmox server and execute: pct restore 104 /vzdump-CTIDHERE.tgz
(104 is the ID of the resulting VPS on Proxmox server)

4. show a configuration of an already existing and working LXC VPS: pct config 101
example result:

net0: name=eth0,bridge=vmbr0,gw=106.154.139.137,hwaddr=3 E:3C:BC:64:38:D5,ip=106.154.139.139/32,type=veth

5. set similar configuration for the VPS you just migrated (only different IP ofcourse):
pct set 104 -net0 name=eth0,type=veth,bridge=vmbr0,gw=107.155.140.13 7,ip=107.155.140.140/32

6. start newly migrated VPS @ make it start at node boot:
pct start 104;pct set 104 --onboot 1

7. enter newly migrated VPS:
pct enter 104

after couple of minutes services on VPS started and i could access/SSH it from internet.