Monday, May 17, 2010

Small OpenVZ admin and backup scripts

I am now using OpenVZ for a while, and by the time I created very small scripts to make my sysadmin life easier.

Update 2013-01-14: as this evolve, I put them on github: StalkR/misc/openvz.

Update 2010-06-10: new scripts and updated some of them. Instead of embedding them in the post, scripts are available here.

You'll find:
  • vz* for OpenVZ, there are many but my favourite is vzl (a nice vzlist)
  • backup-all, to do backups using vzdump (with a powerful backup exclude system), send them to FTP, nice summary output
  • backup-purge, to purge old and no longer valid backups on FTP
  • ftpbackup*, for all FTP backup stuff using lftp: send files, get disk usage, shortcut to send FTP commands

I have put these scripts in /usr/local/sbin and find them useful. Note that many of these scripts depends on others to work properly.

If you like them too, help yourself!

3 comments:

  1. thx for the script, i've done one change in the vzresolvename. I want to be able to use indifferently CTID or NAME to enter my ve (sometimes i do better remember of CTID)
    there my changes to vzresolvename :
    #!/bin/bash
    # Get container id by container name, if it's Hardware Node reply id 0
    [ "$(hostname -s)" == "$1" ] && echo 0 && exit
    if [ `grep -H 'NAME="'$1'"' /etc/vz/conf/*.conf; echo $?` == 0 ]
    then
    grep -H 'NAME="'$1'"' /etc/vz/conf/*.conf | cut -d: -f1 | sed 's,/etc/vz/conf/\([0-9]*\)\.conf,\1,'
    else
    ls /etc/vz/conf/*.conf | grep $1 | sed 's,/etc/vz/conf/\([0-9]*\)\.conf,\1,'
    fi

    ReplyDelete
  2. You're welcome! I'm glad to see it helped someone else, that you modified to fit your needs, and shared back :)

    ReplyDelete
  3. Thank you very much, so I hadn't to write it by my own :)

    ReplyDelete