0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

毎日バックアップ

Posted at
  • MySQLのDBをバックアップ
  • 毎日実行する
  • 30日分確保する
  • 30日より前のものは削除する
#!/bin/sh
umask 077

#30日分世代管理
period=30
dirpath='/path/to/db_back'

#ファイル名
filename=`bkup +%y%m%d`

# ダンプ実行
mysqldump --single-transaction -u username --password=xxxxxxxx db_name | gzip > $dirpath/$filename.sql.gz

# 古いバックアップファイルを削除
oldfile=`date --date "$period days ago" +%y%m%d`
rm -f $dirpath/$oldfile.sql.gz

そんな処理

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?