Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 15th, 2012  |  syntax: Bash  |  size: 0.42 KB  |  views: 153  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2.  
  3. if [ -e /tmp/cronlock ]
  4.         then
  5.         echo "cronjob locked"
  6.         logger backup_db.sh Failed, Is Job Already Running?
  7.         exit 1
  8. fi
  9.  
  10. touch /tmp/cronlock
  11.  
  12. for I in $(mysql -uprimabackup -p36bz2jkz1eczzc3na9ln -e 'show databases' -s --skip-column-names );
  13.         do mysqldump -uprimabackup -p36bz2jkz1eczzc3na9ln $I | bzip2 -c > "/var/dbbackups/$I.sql.bz2";
  14. done
  15.  
  16. rm -f /tmp/cronlock
  17.  
  18. logger backup_db.sh Success
clone this paste RAW Paste Data