rsync + ssh でのバックアップ

computer — Hidekichi @ 2007/4/25 水曜日

データのバックアップ手順を見直したので、改めてメモ。

今回バックアップするのは、ウェブサーバのデータ。バックアップ先は玄箱のDebian。

両方にsshとrsyncが入っているのが前提で、

玄箱側で、

sshd_config

# Don’t read the user’s ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
IgnoreRhosts no
# For this to work you will also need host keys in /etc/ssh_known_hosts
#RhostsRSAAuthentication no
RhostsRSAAuthentication yes
# similar for protocol version 2
#HostbasedAuthentication no
HostbasedAuthentication yes
# Uncomment if you don’t trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

同じ名前の項目があって、片側がコメントアウトされている部分が今回書き換えたところ。

/etc/init.d/ssh restart

/root/.shosts に

192.168.1.1 root

などと、バックアップ元のウェブサーバとバックアップを実行するユーザ名を記述。
ウェブサーバ側で、公開鍵作成

ssh-keygen -t rsa

パスフレーズは空で作成した。

/root/.ssh/id_rsa.pub を玄箱の /root/.ssh/known_hosts および /root/.ssh/authorized_keys に追記。

バックアップ元ウェブサーバから ssh 玄箱 してみて、パスワードを聞かれないのを確認。

実行する rsync のコマンドは、

rsync -az –delete -e ssh バックアップ元ディレクトリ 玄箱の名前:バックアップ先ディレクトリ

crontab -e で cron に登録。

おしまい。

コメント (0) »

この記事にはまだコメントがついていません。

コメント RSS TrackBack URI

コメントをどうぞ

段落や改行は自動挿入です。メールアドレスはサイト上では非表示です。
使用できる HTML タグ: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

HTML convert time: 1.941 sec. Powered by WordPress ME