mysqlbackup.sh 905 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. echo -e '\033[35m
  3. __ __ _ ___ _
  4. | \/ |_ _ ___ __ _| | | _ ) __ _ __| |___ _ _ __ ___
  5. | |\/| | || (_-</ _ | | | _ \/ _ / _| / / || | _ (_-<
  6. |_| |_|\_, /__/\__, |_| |___/\__,_\__|_\_\\_,_| .__/__/
  7. |__/ |_| |_|
  8. \033[0m'
  9. if [ "$EUID" -ne 0 ]; then
  10. echo "Please run as root"
  11. exit
  12. fi
  13. # get the current position
  14. _cwd="$(pwd)"
  15. # check for assets forlder
  16. _assets="$_cwd/assets"
  17. if [ ! -d "$_assets" ]; then
  18. _assets="$_cwd/../assets"
  19. if [ ! -d "$_assets" ]; then
  20. echo "!! can't find assets directory !!"
  21. exit
  22. fi
  23. fi
  24. # adding the script
  25. cp "$_assets"/mysqlbackups.sh /usr/local/bin/
  26. chmod +x /usr/local/bin/mysqlbackups.sh
  27. # creating crontab
  28. touch /var/spool/cron/crontabs/root
  29. crontab -l > /tmp/mycron
  30. echo -e "0 2 */2 * * /usr/local/bin/mysqlbackups.sh" >> /tmp/mycron
  31. crontab /tmp/mycron
  32. rm /tmp/mycron