summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/mariadb/files/dump_mariadb.sh5
-rw-r--r--roles/mariadb/tasks/main.yml4
2 files changed, 9 insertions, 0 deletions
diff --git a/roles/mariadb/files/dump_mariadb.sh b/roles/mariadb/files/dump_mariadb.sh
new file mode 100644
index 0000000..94ff66b
--- /dev/null
+++ b/roles/mariadb/files/dump_mariadb.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+DIR=/var/backups/mariadb/
+[ -d $DIR ] || mkdir -p $DIR
+
+mysqldump --all-databases > $DIR/dump.sql
diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml
index 10783bb..d311b70 100644
--- a/roles/mariadb/tasks/main.yml
+++ b/roles/mariadb/tasks/main.yml
@@ -7,3 +7,7 @@
notify: restart mariadb
- service: name=mariadb enabled=yes state=started
+
+- copy: mode=0755 src=dump_mariadb.sh dest=/usr/local/bin/dump_mariadb.sh
+
+- cron: minute=15 hour=4 name="backup mariadb" job=/usr/local/bin/dump_mariadb.sh