rsync + ssh でのバックアップ
データのバックアップ手順を見直したので、改めてメモ。
今回バックアップするのは、ウェブサーバのデータ。バックアップ先は玄箱の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 に登録。
おしまい。


