Guest User

Untitled

a guest
Jun 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/bin/bash
  2. # Database connection info
  3. user=ssh_username
  4. password=ssh_password
  5. host=ssh_host
  6. db=ssh_database
  7.  
  8. # Filename settings
  9. path=~/dbbackups/
  10. name=dbbackup`date +%y%m%d`.sql.bz2
  11. link=dbbackup.sql.bz2
  12.  
  13. # Dump and bzip the databases
  14. mysqldump --add-drop-table \
  15. --user=$user --password=$password --host=$host \
  16. --databases $db \
  17. | bzip2 > $path$name
  18.  
  19. # Symlink the newest backup to a static filename
  20. ln -sf $path$name $path$link
  21.  
  22. # Delete backups older than a week
  23. find $path -name "*.sql.bz2" -mtime +7 -type f -delete
Add Comment
Please, Sign In to add comment