Advertisement
Guest User

Untitled

a guest
Jun 18th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. echo "Backing up KB mysql database" >> /home2/xxxx/backups/ftp.worked
  2.  
  3. # (1) set up all the mysqldump variables
  4. FILE=~/backups/zips/yyyyyyykb.sql.`date +%Y_%m_%d`
  5. DBSERVER=127.0.0.1
  6. DATABASE=xxxx_xxxxx
  7. USER=xxxx_xxxxx
  8. PASS=asdfasdf
  9.  
  10. # (2) in case you run this more than once a day, remove the previous version of the file
  11. unalias rm 2> /dev/null
  12. rm ${FILE} 2> /dev/null
  13. rm ${FILE}.gz 2> /dev/null
  14.  
  15. # (3) do the mysql database backup (dump)
  16.  
  17. # use this command for a database server on a separate host:
  18. #mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE}
  19.  
  20. # use this command for a database server on localhost. add other options if need be.
  21. echo "Starting dump to file..." >> /home2/xxxx/backups/ftp.worked
  22. mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} > ${FILE}
  23. echo "Dump complete..." >> /home2/xxxx/backups/ftp.worked
  24.  
  25. # (4) gzip the mysql database dump file
  26. echo "Gzipping file..." >> /home2/xxxx/backups/ftp.worked
  27. gzip $FILE
  28. echo "Gzip complete..." >> /home2/xxxx/backups/ftp.worked
  29.  
  30. # (5) show the user the result
  31. echo "${FILE}.gz was created:" >> /home2/xxxx/backups/ftp.worked
  32. ls -l ${FILE}.gz
  33.  
  34. echo "FTPing file..." >> /home2/xxxx/backups/ftp.worked
  35. ftp -n $HOST >> /home2/xxxx/backups/ftp.worked << END_SCRIPT
  36. quote USER $USER
  37. quote PASS $PASSWD
  38. cd backup
  39. cd sssweb
  40. bin
  41. put ~/backups/zips/backup_`date +%Y_%m_%d`.tgz backup_`date +%Y_%m_%d`.tgz
  42. quit
  43. END_SCRIPT
  44. exit 0
  45. echo "File sent..." >> /home2/xxxx/backups/ftp.worked
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement