2
2

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 5 years have passed since last update.

EC2内でcrontabとmysqldumpを使ってRedmineの自動バックアップを行う

2
Last updated at Posted at 2020-01-06

環境

  • EC2(Linux)
  • Docker

dump実行用シェルファイルを作成

$ vi backupdb.sh

backupdb.shに記述するコマンドは以下。

# !/bin/sh
docker exec mysql mysqldump -u ユーザー名 -pパスワード -h ホスト名 データベース名 > ~/redmineBk.sql

mysqlコンテナの中のmysqldumpを使ってsqlファイルにバックアップ対象のデータを出力します。
ユーザー名やデータベース名などは、redmineコンテナの中のconfig/database.ymlに記載されています(-pとパスワードの間にスペース入れない)。
下記コマンドで参照できます。

$ docker exec -it redmine bash  # redmine用のコンテナを指定
root~ /usr/src/redmine# cat config/database.yml

crontabを設定

cronを使って定期的に自動でバックアップを取得できるように設定しておきます。

$ crontab -e
# 分 時 日 月 曜 実行ファイル
00 19 * * 1-5 /home/ec2-user/backupdb.sh

この場合、毎週月~金曜日の19時にバックアップを取得する設定となっています。
設定したcronは、crontab -lで確認できます。

参考

Redmineのバックアップとリストア
crontabの書き方

2
2
1

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?