среда, 29 апреля 2015 г.

Move your server* to openvz container


Really simple, as usual. What you need:
1) Proxmox(or any other openvz web-frontend)
2) rsync
So basically these 6 steps:
1) Create new container (or create new config in /etc/vz/conf/)
2) Remove all the files in /var/lib/vz/private/ID/
3) Do initial rsync:
rsync -av --numeric-ids --exclude=/boot/* --exclude=/lib/modules/* --exclude=/tmp/* \
 --exclude=/etc/blkid --exclude=/etc/mtab --exclude=/etc/lvm --exclude=/etc/fstab \
 --exclude=/etc/udev --exclude=/proc/* --exclude=/sys/* --exclude=/dev/* \
root@REMOTEHOST:/ /var/lib/vz/private/ID/
4) Stop all the services on remote server(i.e. mysql, apache, etc)
5) Do second rsync:
rsync -av --delete --numeric-ids --exclude=/boot/* --exclude=/lib/modules/* --exclude=/tmp/* \
 --exclude=/etc/blkid --exclude=/etc/mtab --exclude=/etc/lvm --exclude=/etc/fstab \
 --exclude=/etc/udev --exclude=/proc/* --exclude=/sys/* --exclude=/dev/* \
root@REMOTEHOST:/ /var/lib/vz/private/ID/
6) Start your container

And you're done!
* If you're using systemd this will probably fail.

Комментариев нет:

Отправить комментарий