LoginSignup
5
4

More than 5 years have passed since last update.

Redisデータバックアップ方法

Posted at

最近Redisのデータバックアップをしたのでメモ。

:new_moon_with_face:バックアップ

1.データバックアップ('OK'と帰ってきたら完了)
redis-cli save
※saveコマンド実行中は他の処理が行われなくなるので、bgsaveを使う方が良さそう。
 1.redis-cli bgsave
  ※終了したかどうかはlastsaveを使って確認する。
 2.redis-cli lastsave
  ※値が代わったかどうかを確認する。

2.バックアップファイル名をリネーム(わかりやすいように)
mv dump.rdb backup.rdb

3.作成したファイルを安全な場所に退避して終了(リブートやクラッシュしても消えない場所に)


:full_moon_with_face: バックアップデータからの復旧

1.Redisを停止する
/etc/init.d/redis stop

2.バックアップしたファイルに差し替える
mv backup.rdb dump.rdb

3.Redisを起動する
/etc/init.d/redis start

5
4
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
5
4