Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

m
Added crontab/nice example. Also added "vzctl enter" while suspending
Dependencies: sendEmail package for emailing of statistics
 
I recommend using nice and ionice to run this script so it doesn't bring the host to it's knees. Here is an example from my crontab. It runs this script every night at 3:30 AM and my server is just as responsive as if it wasn't running at all.
<pre>
30 3 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c3 /usr/local/scripts/ezvzdump
</pre>
== Changes ==
#!/bin/bash
#
# ezvzdump
#
# Copyright (C) 2008 Alex Lance (alla at cyber.com.au)
# Sponsored by Silverband Pty. Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details: http://www.gnu.org/licenses/gpl.txt
# #
# Instructions
# ------------
#
# This script rsyncs a VE to a specified local directory, suspends the running
# VE, rsyncs again, and then resumes the VE. This creates a stable snapshot of
# the VE directories with minimal downtime.
#
# Once the VE has been dumped out locally, it is rsynced to a remote host. When
# the rsync has completed, a tar archive is created on the remote host. The tar
# archive is compatible with the vzdump tar format, so the VE tar file may be
# later restored with the `vzdump --restore` command.
#
# By tarring the files together on the remote host, the burden of creating
# the tar archive is taken away from the hardware node, and given to the remote
# host / backup server. This ensures that minimal additional CPU/disk resources
# are used on the machine that is running the VE's.
#
# This script runs slow the first time you use it, but from then on it utilizes
# the local and remote stored snapshot directories so that the rsyncs happen
# expediently. The script does not wait for the remote tar process to complete,
# it simply kicks off the tar archive creation and then immediately continues.
#
# This script uses rsync and ssh and assumes that you already have ssh keys
# set up between your hosts. This script was written because vzdump takes too
# backups. This script also puts less strain on the hardware node by finishing
# backups more quickly, and making the remote host do the heavy lifting.
#
# NASTY BUG! Make sure you're not "vzctl enter"ing a VE while it's being
# suspended. On my machine (Ubuntu 2.6.24-24-openvz) it caused the VE to
# zombifiy and I had to reboot the host (including killing the VZ shutdown
# script because it was unable to shutdown the VE/processes.) Just don't do it!
# This section contains variables that require user customisation.
3
edits