2021年5月10日月曜日

ZFS に救われた! FreeBSD data server

 久しぶりに写真の整理をしていて、DataServer(FreeBSD)に放り込んでいた写真を、撮影した年代日付毎のフォルダに入れてゆく作業をしていました。 

Windows10からFreeBSDの共有フォルダが見えるようにしてある(Samba3)ので、操作はWindows上のexplorerから行っていました。 で、2020,2019,2018と降りて行った際に、間違って整理し終えた2018年のフォルダをうっかり消してしまって、真っ青! これは、ゴミ箱からの復帰は有り得ませんし、クラウドにもこのファイルは上げていないし、、、。 

あ、ひょっとして、ZFSファイルなので、定期的にsnapshotを取っていたのではなかっただろうか? と、サーバーにアクセスして;

Crontabの内容(一部)
zfs list -r -t snapshot -o name,creation zroot/home (Windowsとの共有は/usr/homeの下にあるので)としたらやったね! 在りました。 月単位、週単位、日単位、時間単位の4段階でsnapshotを自動作成していました。 cronに設定したら、後は自動なので忘れちゃうのが問題かな?

# zfs list -r -t snapshot -o name,creation zroot/usr/home
NAME                                                    CREATION
zroot/usr/home@zfs-auto-snap_monthly-2020-06-01-00h28   月  6月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-07-01-00h28   水  7月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-08-01-00h28   土  8月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-09-01-00h28   火  9月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-10-01-00h28   木 10月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-11-01-00h28   日 11月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2020-12-01-00h28   火 12月  1  0:28 2020
zroot/usr/home@zfs-auto-snap_monthly-2021-01-01-00h28   金  1月  1  0:28 2021
zroot/usr/home@zfs-auto-snap_monthly-2021-02-01-00h28   月  2月  1  0:28 2021
zroot/usr/home@zfs-auto-snap_monthly-2021-03-01-00h28   月  3月  1  0:28 2021
zroot/usr/home@zfs-auto-snap_monthly-2021-04-01-00h28   木  4月  1  0:28 2021
zroot/usr/home@zfs-auto-snap_weekly-2021-04-18-00h14    日  4月 18  0:14 2021
zroot/usr/home@zfs-auto-snap_weekly-2021-04-25-00h14    日  4月 25  0:14 2021
zroot/usr/home@zfs-auto-snap_monthly-2021-05-01-00h28   土  5月  1  0:29 2021
zroot/usr/home@zfs-auto-snap_weekly-2021-05-02-00h14    日  5月  2  0:14 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-04-00h07     火  5月  4  0:07 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-05-00h07     水  5月  5  0:07 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-06-00h07     木  5月  6  0:07 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-07-00h07     金  5月  7  0:07 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-08-00h07     土  5月  8  0:07 2021
zroot/usr/home@zfs-auto-snap_daily-2021-05-09-00h07     日  5月  9  0:07 2021
zroot/usr/home@zfs-auto-snap_weekly-2021-05-09-00h14    日  5月  9  0:14 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-14h00    日  5月  9 14:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-15h00    日  5月  9 15:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-16h00    日  5月  9 16:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-17h00    日  5月  9 17:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-18h00    日  5月  9 18:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-19h00    日  5月  9 19:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-20h00    日  5月  9 20:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-21h00    日  5月  9 21:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-22h00    日  5月  9 22:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-09-23h00    日  5月  9 23:00 2021
zroot/usr/home@zfs-auto-snap_hourly-2021-05-10-00h00    月  5月 10  0:00 2021

で、早速作業を始める前の時間のsnapshotを適用

# zfs rollback -r zroot/usr/home@zfs-auto-snap_hourly-2021-05-10-09h00 

数分で終了したので、Windowsのexplorerで確認すると、在りました! 

あー、良かった。 二時間ほどの作業は無駄になりましたが、無くならなくてよかった。何の気なしに、cron に設定しておいたsnapshotに救われました。

ZFS様様です。 今度HDDからSSDに替えてスピード上げてやろう! 


 

0 件のコメント:

php のインストールの確認

phpって最初のfacebook書くときに使われたみたいで、それなりに歴史のある言語で、私も2006年位から使っていますが、CLIで使う事はあまり無いので、apacheとの連携のトラブル(mod_phpのバージョンの齟齬)などは気になりますが、拡張モジュールのインストールの問題に...