Lastmodified &lastmod;
#counter([total|today|yesterday]);
----
Contents
#contents
http://www.infoscience.co.jp/technical/rsync/rsync.html#option
*rsync error: some files/attrs were not transferred [#s329bc1c]
rsync でサーバ間バックアップの、
 /usr/local/bin/rsync -av / www.smb.net:/usr/Backups/hotshot/
をすると、
----

 var/virusmails/virus-yZtcv94rrLED
 var/virusmails/virus-zZx7Ezo+hqRz
 
 sent 169164700 bytes  received 917357 bytes  291485.96 bytes/sec
 total size is 14195718340  speedup is 83.46
 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1040) [sender=3.0.5]
とエラーする。

http://www.infoscience.co.jp/technical/rsync/rsync.html#option
----
*Rsync de backup [#y22e59e5]
FreeBSD 6.xな外向けのメールサーバのアーカイブを別のサーバにバックアップしよう、というメモ。rsyncで簡単に実現出来ないだろうかと。
WebDAVでもよいけれど、バックアップ用途ならばrsyncのほうが性能を出せるかも。WebDAVにはhttp(80/tcp)を開けるだけという手軽さがあるけど、rsyncもsshを開けるだけで、手軽さという意味では変わらないと思う。


**rsyncのちょっといいオプションを知った夏の一日 [#q1d5b35d]
http://blog.livedoor.jp/tuzzy92/archives/52541703.html

その名は --inplace

# man rsync | grep inplace
--inplace update destination files in-place

意味は
ファイルの中身の一部分を変更する場合に、目的のファイルに直接書き込んでしまうことを指示。このオプションが無い場合、一時ファイルを作って完成してから置き換える。ギガ単位の巨大なファイルをバックアップする場合は必須。 

※http://omake.accense.com/wiki/LinuxBackupScript より引用




**FreeBSDの準備 [#q0e1fdad]
は、実はあまりない。~
FreeBSDは5.xの頃から、デフォルトではsshdすら起動しない設定だが、これを修正する。

vi /etc/rc.conf
 sshd_enable="YES"

とだけ書いておけばいい。デフォルトではパスワード認証を許可しない(公開鍵認証のみ)という、少し厳しめの設定がされていて、通常運用では修正が必要だが、今回はそのままでもいい鴨。
portsから
**rsyncをインストール [#afb324ce]
する必要があるので、
 # portinstall net/rsync

しておく。rsyncdを起動する必要もないので、インストール後の設定も不要。至ってシンプルだ。
#ref(rsync_option.gif)
リモートのファイル転送では、プッシュ(被バックアップ側が処理を実行)かプル(バックアップサーバ側が処理を実行)かという実装の選択肢があるが、今回はプッシュで行くことにする。

公開鍵の登録、バックアップ先ディレクトリの設定等を行い、被バックアップ側の各ホストに、バックアップの実行ユーザー(例えば 'backupman')を作成しておいてもよいだろう。
そして、その実行ユーザーのホームディレクトリに、シンボリックリンクを集めたディレクトリを作る。

 > mkdir ~/Backups_rsync
 > cd ~/backup
 > ln -s /etc etc
 > ln -s /usr/local/etc local.etc
 > ln -s /usr/local/www/data htdocs
 > ln -s /usr/local/mailman mailman
あとは以下のコマンド

といった具合に。
お察しの通り、これらはバックアップ対象ディレクトリへのシンボリックリンク。お好みに合わせて、好きなだけリンクを作るといい。

以上の準備が終われば、あとは以下のコマンド
 /usr/local/bin/rsync -vzrptgoL --delete /root/Backups/ piano.smb.net:/usr/Backups/Hotshot/
を用意する。なお、コマンドオプションで、-avz としたいところであろうが、-a は、-rlptgoD オプションと同義であり、l を含むため、コピー元のシンボリックリンクまで反映してしまい、か・な・り・ファンキーなことになってしまうので要注意!!~
テストすると、
     :      :
 mailman/tests/msgs/
 mailman/tests/msgs/bad_01.txt
 
 sent 430859674 bytes  received 217148 bytes  6029046.46 bytes/sec
 total size is 560331906  speedup is 1.30
と動作確認できる。このままcrontabに書き込むのはちょっと長いので
vi /root/bin/backup_to_piano.sh  として
/root/bin/backup_to_Guard_all.sh 
 #!/bin/sh
 /usr/local/bin/rsync -vzrptgoL --delete /root/Backups/ piano.smb.net:/usr/Backups/Hotshot/
というコマンドをつくり
 /usr/local/bin/rsync -av --exclude="/usr/freebsd-update" --delete / guard.kuji-clinic.info:/usr/Backups/Flola_all/

を用意する。

 # ./root/bin/backup_to_Guard_all.sh

などとして、動作確認した後、

**crontabに書き込む [#tde4522a]
だけだ。

vi /etc/crontab
 # Backup to Piano
 30	2	*	*	*	root	/root/bin/backup_to_piano.sh

**鍵交換認証 [#n6b51802]
http://phys8.s.chiba-u.ac.jp/nakayamal/machines.html#ssh02

アクセスする側で、
 ssh-keygen -b 1024 -t dsa
してid_dsa.pubを作り、アクセス先の~foo/.ssh/へhotshot_id_dsa.pub などとリネームの上コピーし、
  % cp hotshot_id_dsa.pub authorized_keys
する。既にauthorized_keys が存在している様なら、
 % cat ~/.ssh/hotshot_id_dsa.pub >> ~/.ssh/authorized_keys 
 % chmod 600 ~/.ssh/authorized_keys
で、追加書き込みになります。 
***piano2nd.smb.net のマシンを入れ替えたので・・・ [#p28a12f5]
 piano2nd# pwd
 /root
 piano2nd# ssh-keygen -b 1024 -t dsa
 Generating public/private dsa key pair.
 Enter file in which to save the key (/root/.ssh/id_dsa):
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in /root/.ssh/id_dsa.
 Your public key has been saved in /root/.ssh/id_dsa.pub.
 The key fingerprint is:
 54:30:1f:97:84:61:da:03:a6:bd:d8:7f:16:e0:00:bb root@piano2nd.smb.net
 The key's randomart image is:
 +--[ DSA 1024]----+
 |      . =.=+o.   |
 |       * O.o.    |
 |      o = =      |
 |       = + o     |
 |      E S . .    |
 |         .   .   |
 |          . o    |
 |           o     |
 |                 |
 +-----------------+

 ns# scp piano2nd:/root/.ssh/id_dsa_piano2nd_2012.pub /root/.ssh/
 ssh: piano2nd: No address associated with hostname
 ns# scp piano2nd.smb.net:/root/.ssh/id_dsa_piano2nd_2012.pub /root/.ssh/
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
 Someone could be eavesdropping on you right now (man-in-the-middle attack)!
 It is also possible that the DSA host key has just been changed.
 The fingerprint for the DSA key sent by the remote host is
 d6:aa:4b:2b:3b:fc:9c:0b:cd:c9:0f:f4:7f:0c:33:50.
 Please contact your system administrator.
 Add correct host key in /root/.ssh/known_hosts to get rid of this message.
 Offending key in /root/.ssh/known_hosts:12
 DSA host key for piano2nd.smb.net has changed and you have requested strict checking.
 Host key verification failed.
 ns#
 ns#
 ns# scp piano2nd.smb.net:/root/.ssh/id_dsa_piano2nd_2012.pub /root/.ssh/
 The authenticity of host 'piano2nd.smb.net (219.117.246.211)' can't be established.
 DSA key fingerprint is d6:aa:4b:2b:3b:fc:9c:0b:cd:c9:0f:f4:7f:0c:33:50.
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added 'piano2nd.smb.net' (DSA) to the list of known hosts.
 Password:
 id_dsa_piano2nd_2012 100% |*************************************************************************************************************|   611       00:00
 id_dsa_piano2nd_2012 100% |***********************************************|   611       00:00
 ns#

**To Do [#k3c49221]
世代バックアップへの対応、ウィルスチェック等が今後の課題か。
マシンAにマシンBでのユーザー情報を追加する作業 




http://blog.b-shock.co.jp/pooza/2006/01/freebsd_60.html

http://locs.bw.nitech.ac.jp/~kobayashi/computer.html#fedora03
----
#counter([total|today|yesterday]);
&lastmod;
----


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS