ãããããã¡ã¤ã«ãã©ã¼å¦çãã¾ã¨ããrubyã¯ã©ã¹ãä½ã£ã
rsync ãã¢ã¬ã³ã¬è¦ãããã¨å¤ãã¦æ°ã«å
¥ããªããRubyã§ãã©ã¼ãã¼ã«ä½ã£ã¦ãã ã
ãµã¤ãã®æ´æ°ä½æ¥ãããã¸ã«ã¡ã®ããã¯ã¢ãããPCç°å¢ãªã©ãããã¤ãããã¿ã¼ã³ããããã³ã¬ã«åããrsync ãèãããæ¼ãã®ãªããã¸ãã¯èããã®ããæ¯åèããã®ãé¢åã«ãªã£ã¦ããï¼
ããã£ã¨åºæ¥ãããã«ãRubyã§ã¯ã©ã¹æ¸ãã¾ããï¼
ãããªæ©ã¿ã«ãªã¹ã¹ã¡
ãã¡ã¤ã«åæã®ãããªæ©ã¿ã«ãªã¹ã¹ã¡ã§ãï¼
- ä¸æ¸ããããï¼ãã¡ã¤ã«æ¶ããã»ã»ã»
- éä¿¡å ã§ãã¡ã¤ã«åãå¤ãã£ã¦ã¦ãã´ããã¡ã¤ã«ãå¢ãã
- éä¿¡å ã®ãã¡ã¤ã«ãå¥åã«ãã¦ããã転éãã
- åããã¡ã¤ã«ãå¥åã§ããã¤ããã
- æ´æ°æ¥ä»ã®æ°ããã¢ãã ãã転éãããã
- ãã¡ã¤ã«ã®ä¸èº«ãã¿ã¦åæãã¦ã»ããã
rbsyncã§è§£æ±º
- ãã¡ã¤ã«åãå¤ãã£ã¦ãã¦ããåæããã
- ãã¡ã¤ã«åãè¡çªãããï¼å¥åã§è»¢éããã
ããã ãããããããã¼ã«ç¡ããã§ããããWindowsã¢ããªã¯ç°¡åã«èªååã§ããªãã®ã§ã
ã¤ã³ã¹ãã¼ã«
gem instal rbsync
2011-06-14ã®ææ°ç㯠0.0.7
rubyãã使ãã¾ãï¼
require 'rbsync' rbsync = RbSync.new rbsync.sync("src","dest")
ãã¡ã¤ã«åãéã£ã¦ãåæãã¦ï¼
ãã¡ã¤ã«ãããã¯ã¢ããããããã©ï¼ãã¡ã¤ã«åãæ¸æãã¦ãã¾ã£ã¦ï¼ã¦ããåæã§ããªãã¨ããããã¾ããã¾ããå¤äººæ°ã§ãµã¼ãã¼å¼ã£ã¦ãã¨ã誰ãããããªããã¡ã¤ã«åãå¤ãã¦ããããã¦å°ãã¾ãï¼
ãã¡ã¤ã«ã®ããã·ã¥å¤ããã¼ã¹ã«åæãã¦ã¿ããã©ãã
ãã¡ã¤ã«åãå¤ãã£ã¦ãã¦ããä¸èº«ãåããªãï¼åæ対象ããé¤å¤ã§ããã¯ãï¼
ãã£ã¦ã¿ã
require 'rbsync' rbsync = RbSync.new rbsync.sync("src","dest",{:check_hash=>true})
src | test.txt | "47bce5c74f589f4867dbd57e9ca9f808" |
dst | test.bak | "47bce5c74f589f4867dbd57e9ca9f808" |
ããã·ã¥ãåããªã転éããªãï¼
ä¸æ¸ãããåã«ããã¯ã¢ããã¨ã£ã¦ï¼
åæããã¨ãã«ãä¸æ¸ããããªãï¼å ãã¡ã¤ã«ã®ååãå¥åã«ãã¦ãã転éãã¿ããå®å ¨ãªæ°ããã¦ä½ã£ã¦ã¿ãï¼
å ãã¡ã¤ã«ãå¥åã«ä¿åãã¦ãã転éãã¦ã¿ããã©ãã
ãã£ã¦ã¿ã
å
src | test.txt | 2011-06-14 |
dest | test.txt | 2011-06-12 |
å¾
src | test.txt | 2011-06-14 |
dest | test.txt | 2011-06-14 # åæãããã¡ã¤ã« |
dest | test_20110614022255.txt | 2011-06-12 # ä¿åãã¡ã¤ã« |
ruby ã®ã³ã¼ã
require 'rbsync' rsync =RbSync.new rsync.sync( "src", "dest",{:backup=>true,:update=>true} )
åæããã¨ãã«ãå¥åã§åæãã
Windowsã®ãã¡ã¤ã«ã³ãã¼ã¿ããã«ï¼åããã¡ã¤ã«åãããã°ãå¥åã«ãã¦è»¢éããã°è¯ãããããªããã
ããæã£ã¦ä½ã£ã¦ã¿ã
windowsçã«test(1).txt ã«ãã¦æ¬²ããï¼
å®è£ ãã
åæå
src | test.txt | 2011-06-14 |
dest | test.txt | 2011-06-12 |
åæå¾ã®ç¶æ
src | test.txt | 2011-06-14 |
dest | test(1).txt | 2011-06-14 # å¥åãã¤ãã¦è»¢é |
dest | test.txt | 2011-06-12 |
使ãæ¹
require 'rbsync' rsync =RbSync.new rsync.sync( "src", "dest",{:rename=>true} )
ã¾ã ä½ã£ã¦ãªã
- SCP/FTP/SSH çµç±ã§ã®è»¢éï¼
- ä»ã®ã¨ãããããã¯ã¼ã¯è¶ãã®è»¢é㯠smbclient/ sshfs ãæ¿ããã«ä½¿ã
é²æ表示ï¼ããã°ã¬ã¹ãã¼ãã¤ãã£ããã¹ãçã«å®è£ ãã¦ã
便å©ãªã®ã§ä½¿ã£ã¦ã¿ã¦ã¯
便å©ã«ãªãã¨æãã®ã§ä½¿ã£ã¦è¦ã¦ä¸ããã
æã£ããã¨ãªã©
ãã£ã¬ã¯ããªããã©ã¼ããã¨ãã«ï¼ãã¤ããã¡ã¤ã«åãï¼ä¸æ¸ããæ°ã«ããªãããããé¢åã ã
ãã¤ãåãäºãã£ã¦ãã¨æ³ã£ãã®ã§ã¯ã©ã¹ãä½ãã¾ããã
ãããã¿ã¤ããªã®ã§èª¤ä½åããããããããªãã§ãï¼å ±åããããã°å ¨åã§å¯¾å¿ãã¾ãï¼
ä¼æ¥ãçªã£è¾¼ãã§ä½ã£ããï¼ãã¡ã¤ã«ã¯æä½æ¥ã§ã³ãã¼ããã®ã§ï¼æ´»èºã®æ©ä¼ããã¾ããªãï¼ããã
ä½ã£ãçµç·¯ rsyncã®å¤§å¤±æ
rsync ã使ãè¾¼ãã§ããããã§ã失æããï¼
HTC Desireã®ã«ã¡ã©ã¢ããªãåé¤ãããã¡ã¤ã«åãåå©ç¨ããã®ã§ï¼åæå¾ã«ï¼ãã¸ã«ã¡ãã¡ã¤ã«ã大éã«æ¶ãããã¤ã©ãã¨ãã¦ä½ã£ãï¼
ScanSnapã®ãã©ã«ããRsyncãã¦ããã ãã©ãååãå¤ãã¾ãã£ã¦ï¼åæåºæ¥ãªããªã£ãã®ã§ã¤ã©ãã¨ãªã£ã¦ä½ã£ãï¼
è¿½è¨ 2011-06-14 17:38
ã»ãµããã£ã¬ã¯ããªã®å¦çãã¨ã©ã¼ã«ãªã£ãã®ãä¿®æ£
ã»ãã¹ãã«ã¿ã¤ã ã¹ã¿ã³ããã§ãã¯ã追å
ã»ctimeã®å¦çãWindows/Linux/Cygwinã§å¾®å¦ã«éãã®ã§ã¯ã¾ãããï¼
è¿½è¨ 2011-06-14 3:38
ããã°ã¬ã¹ãã¼ãä½ã£ãï¼ãããªæãã§åºãããã«ãªã£ãï¼
ããã°ã¬ã¹ãã¼ä½¿ã
rsync = RbSync.new rsync.conf[:progress] = true # é²æ表示 rsync.sync("/home/takuya/desktop/src","/home/takuya/desktop/dest" )
表示ãµã³ãã«
$ ruby sample_sync.rb start 4/9 copying ./src/éå¼ãRubyã¾ã¨ããã¼ã(1).pdf to ./dest/éå¼ãRubyã¾ã¨ããã¼ã(1).pdf ############################## 100% done start 7/9 copying ./src/éã³ããã-10.11.pdf to ./dest/éã³ããã-10.11.pdf ############################## 100% done start 8/9 copying ./src/éªæ¥TOKK-10-01ç.pdf to ./dest/éªæ¥TOKK-10-01ç.pdf ############################## 100% done start 9/9 copying ./src/éªæ¥TOKK-10-15ç.pdf to ./dest/éªæ¥TOKK-10-15ç.pdf ############################## 100% done
è¿½è¨ 2011-06-15 0:25
Windowsã®Rubyã¯ãã¡ã¤ã«ã®æ´æ°æ¥æãããªç§åä½ã§ã¯åãã¾ããï¼
å®è£
ä¾åãããã®ã§ãWindowsã®å ´åã¯Winï¼ï¼ã使ãããã«æ¸æããªãã¨ãã¡ã¿ããï¼
è¿½è¨ 2011-07-10
ã¨ã©ã¼ä¿®æ£ãã¹ã¬ããåä½ã®ä¿®æ£ãã¹ã¬ãããFile.size(entry)ã§Errorã«ãªã£ã¦ãã®ãä¿®æ£ã ã¹ã¬ããããã¡ã¤ã«ä½æåã«sizeãå®è¡ãã¦NotFoundã¨ã©ã¼ã§è½ã¡ã¦ãã
cygwin ã®æ¥æ¬èªUTF8/SJISç°å¢ã§ File#dirname ãã²ãããªãã¹ã ã¨ã¦ããåãåºããªãã£ãã®ã§é©å½ã«ä¿®æ£
è¿½è¨ 2011-07-28
ãã¡ã¤ã«ãã§ãã¯ãåé·ã§ããã¡ã¤ã«ãµã¤ãºãä½åãåãã«è¡ã£ã¦ãã¨ãããä¸ã«æã ãçç¥ããã