Guest User

Untitled

a guest
Mar 9th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This is where the backup gets emailed too
  4. BACKUPMAIL=test@gmail.com
  5. DATE=`date`
  6. DATABASEUSER=root
  7. DATABASEPASS=secret
  8. DATABASENAME=test
  9.  
  10. PREFIX=topup_
  11. NOW="$(date +"%d-%m-%Y")"
  12.  
  13. PATH=/usr/home/freebsd/backup/mysql/
  14. cd ${PATH}
  15.  
  16. #dump DB
  17. /usr/local/bin/mysqldump --opt -u${DATABASEUSER} -p${DATABASEPASS} ${DATABASENAME} > ${DATABASENAME}.sql
  18.  
  19. # Archive for storage purpose
  20. /usr/bin/tar -zcvf ${PREFIX}${NOW}.tgz *.sql
  21.  
  22. # Zip send to me
  23. /usr/bin/gzip -c ${DATABASENAME}.sql | /usr/bin/uuencode ${DATABASENAME}.sql.gz | /usr/bin/mail -s "MySQL DB ${DATABASENAME} for $DATE" ${BACKUPMAIL}
  24.  
  25. #Remove SQL files
  26. /bin/rm /usr/home/freebsd/backup/mysql/*.sql
  27.  
  28. # Delete files older than 30 days
  29. /usr/bin/find ${PATH}* -mtime +30 -exec /bin/rm {} \;
Add Comment
Please, Sign In to add comment