isseium's blog

田舎に住むWebエンジニアのブログ

redis のデータが消えた!

と、思ったら、間違いでした。

redis に付属の redis.conf のデフォルト設定で、データファイルは ./ (カレントディレクトリ)の dump.rdb に格納されているんですね!




redis.conf (デフォルトのものを加工しているので、行番号は数行ずれてます)

     99 # The filename where to dump the DB
    100 dbfilename dump.rdb
    101 
    102 # The working directory.
    103 #
    104 # The DB will be written inside this directory, with the filename specified
    105 # above using the 'dbfilename' configuration directive.
    106 #
    107 # Also the Append Only File will be created inside this directory.
    108 #
    109 # Note that you must specify a directory here, not a file name.
    110 dir ./

110行目のパスに、100行目のファイルで保存します、ということですね。
違うパスで起動したら、そりゃ空になりますわ。


dir を絶対パスにすればどこで起動しても大丈夫になるんだと思います!

dir /var/redis/

のような感じ?(未確認)



話はもどって、confをデフォルトのまま利用してて、かつ、どこで起動したかわからないときは、find さんに頼りましょう。

sudo find / -name dump.rdb


僕はこれで事なきを得ました。