Created
January 6, 2016 08:54
-
-
Save kurozumi/3cdc97dd511f01fa2cbb to your computer and use it in GitHub Desktop.
【シェルスクリプト】一週間分だけ定期的にデータベースをバックアップする方法
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/sh | |
period=7 | |
filename=`date +%y%m%d` | |
oldfile=`date --date "$period days ago" +%y%m%d` | |
dir_path="/home/username/db_backup" | |
mysqldump -u username -ppasswd database_name > $dir_path/$filename.sql | |
chmod 700 $dir_path/$filename.sql | |
rm -f $dir_path/$oldfile.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment