Create Daily RHEVM Backups

By | 2015/08/20

Create Daily RHEVM Backups

RHEV out of the box does not provide any backups for the RHEV Manager, or RHEVM. However, you can script up a daily backup of RHEVM. Check it out!


1. First, ssh into rhevm and make a backup directory

sudo mkdir /var/lib/ovirt-engine-backups/

2. Next, create the following file and use my script as a general guide.

File:

/usr/local/bin/backuprhevm.sh 



Contents:

#!/usr/bin/env bash
#
# See https://access.redhat.com/solutions/797463
#
/usr/bin/engine-backup --mode=backup --scope=all --file="/var/lib/ovirt-engine-backups/engine-backup-$(hostname)-$(date +%F).tar.bz2" --log=/var/log/ovirt-engine-backups.log

# (Optional) rsync backup to some other host for long term storage
# /usr/bin/rsync -azv -e ssh /var/lib/ovirt-engine-backups/*.bz2 172.16.0.125:/mnt/archive/rhevm/$(hostname)/

# (Optional) rm backups older than 7 days | keep 7 days of backups local
find /var/lib/ovirt-engine-backups/ -name "*.bz2" -mtime +7 -exec rm -rf -- {} \;

3. Make that file executable

sudo chmod +x /usr/local/bin/backuprhevm.sh


4. If desired, run the script manually to make sure all works ok.

sudo /usr/local/bin/backuprhevm.sh

5. Finally, edit root’s crontab and make an entry for this script to run daily.

sudo crontab -e
# rhevm backup run daily at 02:30
30 2 * * * /usr/local/bin/backuprhevm.sh >/dev/null 2>&1


Done!

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.