• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# A cron job may call this with a line such as:
4#     53 14 * * * sh /home/cldrbackup/backup.sh >/dev/null 2>&1
5# It may be configured by an ansible script such as backup-db-playbook.yml
6#
7# The backups might be made faster by saving the sql file in a fast
8# temporary directory (mktemp? /mnt?) -- let's test that at a time
9# when Survey Tool is closed and daily backups aren't essential
10
11DATABASE_NAME={{ cldr_database_name }}
12FNAME={{ cldr_database_name }}-DUMP-`date +%Y-%m-%d`
13RSYNC_DEST={{ cldr_db_backup_destination }}
14
15cd /home/cldrbackup
16mysqldump ${DATABASE_NAME} --add-drop-table --create-options --default-character-set=utf8mb4 > ${FNAME}.sql
17
18# Wait until mysqldump is finished before running xz, to minimize db disruption (don't use | pipe)
19xz ${FNAME}.sql
20rsync -q ${FNAME}.sql.xz ${RSYNC_DEST}
21