Skip to content

Commit

Permalink
Backup dumps of domservers to admin machines
Browse files Browse the repository at this point in the history
Also updated the load-db script to allow loading those dumps from
alternative locations.
  • Loading branch information
vmcj committed Apr 11, 2024
1 parent 23da494 commit 274214b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
13 changes: 11 additions & 2 deletions provision-contest/ansible/roles/mysql_server/files/load-db
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ then
exit 1
fi

FILE="/home/domjudge/db-dumps/${1}.sql.gz"
FILEHOME="/home/domjudge/db-dumps/${1}.sql.gz"
FILEBACKUP="/home/domjudge/db-dumps-backup/${1}.sql.gz"

if [ ! -f "${FILE}" ]
if [ -f "${FILEHOME}" ]
then
FILE="${FILEHOME}"
elif [ -f "${FILEBACKUP}" ]
then
FILE="${FILEBACKUP}"
fi

if [ -z "${FILE++}" ] || [ ! -f "${FILE}" ]
then
echo "Error. File ${FILE} not found"
exit 1
Expand Down
31 changes: 31 additions & 0 deletions provision-contest/ansible/sync_dumps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- hosts: domserver
tasks:
- name: Create directory to collect backups
file:
state: directory
owner: root
group: root
mode: 0755
path: "/srv/db-dumps"

- name: Download dumps to ansible machine
synchronize:
mode: pull
src: "/home/domjudge/db-dumps/"
dest: "/srv/db-dumps/"

- hosts: admin
tasks:
- name: Create directory to collect backups
file:
state: directory
owner: domjudge
group: domjudge
mode: 0755
path: "/home/domjudge/db-dumps-backup"

- name: Download dumps to admin machines
synchronize:
dest: "/home/domjudge/db-dumps-backup/"
src: "/srv/db-dumps/"

0 comments on commit 274214b

Please sign in to comment.