Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Database connection info
- user=ssh_username
- password=ssh_password
- host=ssh_host
- db=ssh_database
- # Filename settings
- path=~/dbbackups/
- name=dbbackup`date +%y%m%d`.sql.bz2
- link=dbbackup.sql.bz2
- # Dump and bzip the databases
- mysqldump --add-drop-table \
- --user=$user --password=$password --host=$host \
- --databases $db \
- | bzip2 > $path$name
- # Symlink the newest backup to a static filename
- ln -sf $path$name $path$link
- # Delete backups older than a week
- find $path -name "*.sql.bz2" -mtime +7 -type f -delete
Add Comment
Please, Sign In to add comment