Last active
December 10, 2018 19:58
-
-
Save johnsimcall/09c8c32c9a288d21780326df35db6cb8 to your computer and use it in GitHub Desktop.
Cron file to backup RHV-M database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: /etc/cron.daily/rhvm-backup.sh | |
# author: jcall | |
# purpose: backup RHV-M database daily | |
# pre-requisites: "yum -y install tmpwatch" | |
#!/bin/bash | |
BACKUP_DIR="/var/rhvm-backups" | |
BACKUP_FILE="${BACKUP_DIR}/rhv-engine-backup-$(date +"%F_%T")" | |
BACKUP_DAYS=7d | |
mkdir ${BACKUP_DIR} | |
/usr/bin/engine-backup --scope=all --mode=backup \ | |
--log="${BACKUP_FILE}.log" \ | |
--file="${BACKUP_FILE}.tar.bz2" | |
if $(type -p tmpwatch 2>&1 > /dev/null); then | |
echo "Removing old backups..." | |
tmpwatch --verbose --mtime ${BACKUP_DAYS} ${BACKUP_DIR} | |
else | |
echo "Unable to remove old backups. \"tmpwatch\" not installed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this file on your RHV-M server in /etc/cron.daily and make it executable like this: