Created
March 3, 2013 08:03
-
-
Save taiko19xx/5075264 to your computer and use it in GitHub Desktop.
mysqldump with gzip(monthly)
This file contains 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 | |
_dir='/path/to/target/' | |
_target=`date +"%Y%m"` | |
if test ! -d $_dir$_target | |
then | |
mkdir $_dir$_target | |
_last=`date -d '1 month ago' +"%Y%m"` | |
if test -d $_dir$_last | |
then | |
cd $_dir | |
tar cvzf ${_last}.tar.gz $_last | |
rm -rf $_dir$_last | |
fi | |
fi | |
_file=`date +"%Y-%m-%d"` | |
cd $_dir$_target | |
mysqldump -uxxx -pxxx database > ${_file}.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment