Browse Source

added mysqlbackup script

Bachir Soussi Chiadmi 5 years ago
parent
commit
a791eb949f
3 changed files with 43 additions and 1 deletions
  1. 41 0
      bin/mysqlbackup.sh
  2. 1 0
      install.sh
  3. 1 1
      readme.md

+ 41 - 0
bin/mysqlbackup.sh

@@ -0,0 +1,41 @@
+#!/bin/sh
+
+echo -e '
+  __  __               _   ___          _
+ |  \/  |_  _ ___ __ _| | | _ ) __ _ __| |___  _ _ __ ___
+ | |\/| | || (_-</ _  | | | _ \/ _  / _| / / || |  _ (_-<
+ |_|  |_|\_, /__/\__, |_| |___/\__,_\__|_\_\\_,_| .__/__/
+         |__/       |_|                         |_|
+'
+
+. bin/checkroot.sh
+
+# get the current position
+_cwd="$(pwd)"
+# check for assets forlder
+_assets="$_cwd/assets"
+if [ ! -d "$_assets" ]; then
+  _assets="$_cwd/../assets"
+  if [ ! -d "$_assets" ]; then
+    echo "!! can't find assets directory !!"
+    exit
+  fi
+fi
+
+# adding the script
+cp "$_assets"/mysqlbackup.sh /usr/local/bin/
+chmod +x /usr/local/bin/mysqlbackup.sh
+
+# configure
+echo -n "Please provide the mysql root passwd : "
+read _root_mysql_passwd
+sed -i "s/ROOTPASSWD/$_root_mysql_passwd/g" /usr/local/bin/mysqlbackup.sh
+
+# creating crontab
+touch /var/spool/cron/crontabs/root
+crontab -l > /tmp/mycron
+echo "30 2 */2 * * /usr/local/bin/mysqlbackup.sh" >> /tmp/mycron
+crontab /tmp/mycron
+rm /tmp/mycron
+
+echo -e "mysql backup script installed"

+ 1 - 0
install.sh

@@ -33,6 +33,7 @@ _cwd="$(pwd)"
 . bin/knockd.sh
 # . bin/email.sh
 . bin/lemp.sh
+. bin/mysqlbackup.sh
 # . bin/vhost.sh
 . bin/zabbix.sh
 . bin/urbackup.sh

+ 1 - 1
readme.md

@@ -25,7 +25,7 @@ each alpine linux stable release has it's branch (master is a clone of the last
 - [ ] letsencrypt
 - [ ] vhosts
 - [x] redis
-- [x] zabbix-agent (4)
+- [x] zabbix-agent (3.4 || 4)
 - [x] urbackup-client
 - [ ] solr
 - [ ] git barre repos