Skip to content

Commit 274214b

Browse files
committed
Backup dumps of domservers to admin machines
Also updated the load-db script to allow loading those dumps from alternative locations.
1 parent 23da494 commit 274214b

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

provision-contest/ansible/roles/mysql_server/files/load-db

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ then
77
exit 1
88
fi
99

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

12-
if [ ! -f "${FILE}" ]
13+
if [ -f "${FILEHOME}" ]
14+
then
15+
FILE="${FILEHOME}"
16+
elif [ -f "${FILEBACKUP}" ]
17+
then
18+
FILE="${FILEBACKUP}"
19+
fi
20+
21+
if [ -z "${FILE++}" ] || [ ! -f "${FILE}" ]
1322
then
1423
echo "Error. File ${FILE} not found"
1524
exit 1
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
- hosts: domserver
3+
tasks:
4+
- name: Create directory to collect backups
5+
file:
6+
state: directory
7+
owner: root
8+
group: root
9+
mode: 0755
10+
path: "/srv/db-dumps"
11+
12+
- name: Download dumps to ansible machine
13+
synchronize:
14+
mode: pull
15+
src: "/home/domjudge/db-dumps/"
16+
dest: "/srv/db-dumps/"
17+
18+
- hosts: admin
19+
tasks:
20+
- name: Create directory to collect backups
21+
file:
22+
state: directory
23+
owner: domjudge
24+
group: domjudge
25+
mode: 0755
26+
path: "/home/domjudge/db-dumps-backup"
27+
28+
- name: Download dumps to admin machines
29+
synchronize:
30+
dest: "/home/domjudge/db-dumps-backup/"
31+
src: "/srv/db-dumps/"

0 commit comments

Comments
 (0)