サーバーのよく使うコマンドメモ rsync

2015年2月9日

コマンド サーバー テクノロジー

Summery

データをコピーして、2つのディレクトリ間の同期を行う。

Construction

$ rsync [option] [path1] [path2]

Option

-a : アーカイブモード(パーミッションやグループを保持する) -v : 処理中のファイルをコンソールに表示する -r : 再帰的処理(対象の子階層全て含む) -z : 圧縮して同期を行う --delete : aオプションと同時に使用することで、削除されたファイルを同期先でも削除する --stats : アルゴリズムの転送効率を表示する

Sample

# ディレクトリの同期(ローカル端末内) $ rsync -av ~/hoge/ /media/disk/backup/ # ディレクトリの同期(別サーバーSSH経由) # 自端末 -> domain.com /media/disc/backup $ rsync -av ~/hoge/ user@domain.com:/media/disk/backup/

Coution

対象ディレクトリに"/"を付ける付けないで、挙動がかわる。
1、$ rsync -av ~/hoge/ /media/disk/backup/ 2、$ rsync -av ~/hoge /media/disk/backup/
1番は、ディレクトリ内部が同期され、 2番は、hogeディレクトリ毎同期される。

Discription

rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies this package. Some of the additional features of rsync are: o support for copying links, devices, owners, groups, and permissions o exclude and exclude-from options similar to GNU tar o a CVS exclude mode for ignoring the same files that CVS would ignore o can use any transparent remote shell, including ssh or rsh o does not require super-user privileges o pipelining of file transfers to minimize latency costs o support for anonymous or authenticated rsync daemons (ideal for mirroring)

人気の投稿

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。

ブログ アーカイブ