#!/bin/bash

# first, generate the out-of-mysqld copy
# fill in the right password for -p!
mysqlhotcopy genomics_test --allowold --tmpdir=/opt/tmp/ --method=cp \
	-u genomics -p  \
	/opt/mysql/backup/

# todo: would like to generate autobackups for mysql db
# (but need to be a mysql superuser to do that--don't want to
# put password into a script)

# next, chown the directory to nfsnobody
# (or whoever will have the crontab entry)
# this enables rsync over NFS, so no passwords need to be
# passed anywhere (should be slightly faster than rsync-over-ssh, too)
chown -R 65534 /opt/mysql/backup/*

# finally, rsync over NFS
su - nobody -c \
	'rsync -avz \
	/opt/mysql/backup/ \
	/usr2/people/gtl/mysql-backup/'

# put a job like so in crontab:
# 00 23 * * * /path/to/genomics_test-backup.sh
