SHARE
TWEET

Untitled

a guest Nov 15th, 2012 177 Never
  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
RAW Paste Data
Top