Skip to content

Instantly share code, notes, and snippets.

@johnsimcall
Last active December 10, 2018 19:58
Show Gist options
  • Save johnsimcall/09c8c32c9a288d21780326df35db6cb8 to your computer and use it in GitHub Desktop.
Save johnsimcall/09c8c32c9a288d21780326df35db6cb8 to your computer and use it in GitHub Desktop.
Cron file to backup RHV-M database
# 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
@johnsimcall
Copy link
Author

johnsimcall commented Dec 4, 2018

Put this file on your RHV-M server in /etc/cron.daily and make it executable like this:

$ curl https://gist.githubusercontent.com/johnsimcall/09c8c32c9a288d21780326df35db6cb8/raw/601bc965b18be5a7bd7ba61146de39b5e5a41bd3/rhvm-backup.sh | sudo tee /etc/cron.daily/rhvm-backup.sh
$ sudo chmod a+x /etc/cron.daily/rhvm-backup.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment