Created
November 16, 2016 13:36
-
-
Save asmt3/790c49470e89eddff7667d12e015b67d to your computer and use it in GitHub Desktop.
Script to do regular MySQL backup on TSO Hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Database login credentials - need to be changed accordingly | |
dbHost="***" | |
dbName="**" | |
dbUser="***" | |
dbPass="***" | |
#How many days the backups should be kept for before being removed | |
keepBackupsFor="30" | |
if [ ! -d ~/additional_backups ]; then mkdir ~/additional_backups; fi | |
curTime=$(date +"%m-%d-%y_%H:%M") | |
mysqldump -h ${dbHost} -u ${dbUser} -p${dbPass} ${dbName} > ~/additional_backups/${curTime}-sql_backup.sql | |
find ~/additional_backups -type f -ctime +${keepBackupsFor} -exec rm -f {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crikey, that's disturbingly simple.
I love it!
Thanks a bunch.