Skip to content

Instantly share code, notes, and snippets.

@laurentlemaire
Created October 3, 2014 11:45
Show Gist options
  • Save laurentlemaire/7d970cedeacd1c9dbd94 to your computer and use it in GitHub Desktop.
Save laurentlemaire/7d970cedeacd1c9dbd94 to your computer and use it in GitHub Desktop.
Shell mysql backup script
#!/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