Created
October 3, 2014 11:45
-
-
Save laurentlemaire/7d970cedeacd1c9dbd94 to your computer and use it in GitHub Desktop.
Shell mysql backup script
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/sh | |
# Parameters | |
. export_db-params | |
echo Script start | |
# File cleaning | |
find ${export_path}/* -type f -mtime +15 -delete; | |
# Mysql dump | |
echo Start sql dump | |
NOW=$(date +"%Y-%m-%d") | |
sql_file="log-$NOW.sql" | |
mysqldump --add-drop-table -u ${mysql_login} --password=${mysql_psw} ${mysql_db_name} > $export_path/$sql_file | |
gzip $export_path/$sql_file | |
echo File $export_path/$sql_file created | |
echo Script end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment