This script will read the container ID from the file name, and use it to restore the tgz dump to the same ID on the new OpenVZ/Proxmox server.
Note that this only works if the default name for the vzdumps is kept, and it only works for the next 89 years, because I’m lazy.
Thanks to
http://www.cyberciti.biz/faq/bash-loop-over-file/ and http://bashcurescancer.com/10-steps-to-beautiful-shell-scripts.html
#!/bin/bash
VZDUMPS=/path/to/backups/*.tgz
for f in $VZDUMPS
do
f2=${f#*openvz-}
VEID=${f2%-20*}
echo "Restoring $f to $VEID"
vzrestore $f $VEID
done
2013-11-03 at 22:16
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Hi,
Thanks for the post. I made a similar restore script myself which I use in my dev environment. It restores the latest backup which can be useful if you take several backups over time.
http://www.jamescoyle.net/how-to/824-restore-all-proxmox-openvz-containers-from-the-command-line
Hope this is useful,
James.