Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo "Backing up KB mysql database" >> /home2/xxxx/backups/ftp.worked
- # (1) set up all the mysqldump variables
- FILE=~/backups/zips/yyyyyyykb.sql.`date +%Y_%m_%d`
- DBSERVER=127.0.0.1
- DATABASE=xxxx_xxxxx
- USER=xxxx_xxxxx
- PASS=asdfasdf
- # (2) in case you run this more than once a day, remove the previous version of the file
- unalias rm 2> /dev/null
- rm ${FILE} 2> /dev/null
- rm ${FILE}.gz 2> /dev/null
- # (3) do the mysql database backup (dump)
- # use this command for a database server on a separate host:
- #mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE}
- # use this command for a database server on localhost. add other options if need be.
- echo "Starting dump to file..." >> /home2/xxxx/backups/ftp.worked
- mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} > ${FILE}
- echo "Dump complete..." >> /home2/xxxx/backups/ftp.worked
- # (4) gzip the mysql database dump file
- echo "Gzipping file..." >> /home2/xxxx/backups/ftp.worked
- gzip $FILE
- echo "Gzip complete..." >> /home2/xxxx/backups/ftp.worked
- # (5) show the user the result
- echo "${FILE}.gz was created:" >> /home2/xxxx/backups/ftp.worked
- ls -l ${FILE}.gz
- echo "FTPing file..." >> /home2/xxxx/backups/ftp.worked
- ftp -n $HOST >> /home2/xxxx/backups/ftp.worked << END_SCRIPT
- quote USER $USER
- quote PASS $PASSWD
- cd backup
- cd sssweb
- bin
- put ~/backups/zips/backup_`date +%Y_%m_%d`.tgz backup_`date +%Y_%m_%d`.tgz
- quit
- END_SCRIPT
- exit 0
- echo "File sent..." >> /home2/xxxx/backups/ftp.worked
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement