Last active
May 26, 2019 08:51
-
-
Save techbyvideo/fb10f83c1a1bb939adb8be4c8d5281df to your computer and use it in GitHub Desktop.
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 | |
| #Backups Folder | |
| cd /backups/mysql/ | |
| # Get list of databases | |
| LISTEBDD=$( echo 'show databases' | mysql -uroot -p'techbyvideo' ) | |
| # Save the current date | |
| DATE=`date +%y_%m_%d` | |
| ##List of databases | |
| for SQL in $LISTEBDD | |
| do | |
| if [ $SQL != "information_schema" ] && [ $SQL != "mysql" ] && [ $SQL != "performance_schema" ] && [ $SQL != "Database" ]; then | |
| ## backup database | |
| mysqldump -uroot -p'techbyvideo' $SQL > ${SQL}_`date +"%Y-%m-%d"`.sql | |
| ## Compress file tar.bz2 | |
| tar jcf ${SQL}_`date +"%Y-%m-%d"`.sql.tar.bz2 ${SQL}_`date +"%Y-%m-%d"`.sql | |
| ## delete backups | |
| rm ${SQL}_`date +"%Y-%m-%d"`.sql | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment