mysqlbackup.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. echo -e '
  3. __ __ _ ___ _
  4. | \/ |_ _ ___ __ _| | | _ ) __ _ __| |___ _ _ __ ___
  5. | |\/| | || (_-</ _ | | | _ \/ _ / _| / / || | _ (_-<
  6. |_| |_|\_, /__/\__, |_| |___/\__,_\__|_\_\\_,_| .__/__/
  7. |__/ |_| |_|
  8. '
  9. . bin/checkroot.sh
  10. # get the current position
  11. _cwd="$(pwd)"
  12. # check for assets forlder
  13. _assets="$_cwd/assets"
  14. if [ ! -d "$_assets" ]; then
  15. _assets="$_cwd/../assets"
  16. if [ ! -d "$_assets" ]; then
  17. echo "!! can't find assets directory !!"
  18. exit
  19. fi
  20. fi
  21. # adding the script
  22. cp "$_assets"/mysqlbackup.sh /usr/local/bin/
  23. chmod +x /usr/local/bin/mysqlbackup.sh
  24. # configure
  25. echo -n "Please provide the mysql root passwd : "
  26. read _root_mysql_passwd
  27. sed -i "s/ROOTPASSWD/$_root_mysql_passwd/g" /usr/local/bin/mysqlbackup.sh
  28. # creating crontab
  29. touch /var/spool/cron/crontabs/root
  30. crontab -l > /tmp/mycron
  31. echo "30 2 */2 * * /usr/local/bin/mysqlbackup.sh" >> /tmp/mycron
  32. crontab /tmp/mycron
  33. rm -f /tmp/mycron
  34. echo -e "mysql backup script installed"