LoginSignup
3
2

More than 5 years have passed since last update.

rsyncとtar+mvで作るmac上のThunderbirdのデータバックアップ

Last updated at Posted at 2016-09-14

今更感はありますが、mac+thunderbird使い向けのメールデータのバックアップ設定を、自身の備忘録として書き出します。LAN内でsambaで接続可能なサーバがある環境下でのご活用の参考になればと。

# "{}"で囲んだ値は各自のローカル環境に併せて変更して下さい。

1.rsyncを用いた同期バックアップ

/Users/{ローカルユーザ}/rsync_thunderbird.sh
#!/bin/sh

# mount @{サーバIP}
/sbin/mount_smbfs //{ユーザ}:'{パスワード}'@{サーバIP}/{サーバdir} {ローカルマウントdir}

# rsync files to @{サーバIP}
/usr/bin/rsync -rlopgtu --delete /Users/{ローカルユーザ}/Library/Thunderbird {ローカルマウントdir}

# unmount @{サーバIP}
/sbin/umount {ローカルマウントdir}

2.tar+mvを用いた世代管理バックアップ

/Users/{ローカルユーザ}/archive_thunderbird.sh
#!/bin/sh

# mount @{サーバIP}
/sbin/mount_smbfs //{ユーザ}:'{パスワード}'@{サーバIP}/{サーバdir} {ローカルマウントdir}

# move to work dir
/usr/bin/cd /Users/{ローカルユーザ}/Library/

# archive Thunderbird DIR
/usr/bin/tar -czvf /Users/{ローカルユーザ}/Library/`date "+%Y%m%d"`_Thunderbird.tar.gz /Users/{ローカルユーザ}/Library/Thunderbird/

# move archive file to @{サーバIP}
/bin/mv /Users/{ローカルユーザ}/Library/`date "+%Y%m%d"`_Thunderbird.tar.gz {ローカルマウントdir}

# unmount @{サーバIP}
/sbin/umount {ローカルマウントdir}

※/Users/{ローカルユーザ}/Library/」に移動するのは余剰なディレクトリを介さない様にするちょっとした手間を加えただけです。

shファイルへの実行権限追加もお忘れなく。

chmod +x /Users/{ローカルユーザ}/rsync_thunderbird.sh
chmod +x /Users/{ローカルユーザ}/archive_thunderbird.sh

あとはcrontabに登録します。

00 09 * * * /bin/sh /Users/{ローカルユーザ}/archive_thunderbird.sh 1>/dev/null 2>/dev/null
00 09,12,17 * * * /bin/sh /Users/{ローカルユーザ}/rsync_thunderbird.sh 1>/dev/null 2>/dev/null

「標準出力/標準エラー」の各ログを残しておきたいのであれば「/dev/null」に突っ込まず、適切に書き出し先を指定しておく様にしましょう

他のバックアップの実装より仕様用途を広げて使えるのではないかと思います。
また、Thunderbirdのみとせず、他のバックアップにも用途として向くのであれば利用してみては如何でしょうか?

以上。

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