2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Codeigniterフレームワークアプリをrsyncでコピーしたらうまくいかなかった件

Posted at

##起こったこと
Codeigniterを利用してアプリケーションを作っています。
自動デプロイをしようと思ってgitからcheckoutしたソースをrsyncで公開ディレクトリの同期をしてみました。

 rsync -avC --delete --bwlimit=1250 /src/path/ /application/path/

比べてみると。

diff -r  /src/path/ /application/path/
/application/path/applicationだけに発見: core

なんでや!?

調べてみたこと

man rsync

       -C, --cvs-exclude
              This  is a useful shorthand for excluding a broad range of files
              that you often don’t want to transfer between systems. It uses a
              similar  algorithm  to  CVS  to  determine  if  a file should be
              ignored.

              The exclude list is initialized to exclude the  following  items
              (these  initial  items are marked as perishable ― see the FILTER
              RULES section):

                     RCS  SCCS  CVS  CVS.adm   RCSLOG   cvslog.*   tags   TAGS
                     .make.state  .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak
                     *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so  *.exe
                     *.Z *.elc *.ln core .svn/ .git/ .bzr/

はえーcoreディレクトリは除外されてるやん。みたらわかるーはまるやつやん。

やったこと

以下のように書きました

 rsync -avC --include=core --delete --bwlimit=1250 /src/path/ /application/path/

が本当は横着せずにきちんとexclodeをつなげて書くほうがいいのかもしれません。

 rsync -av --exclude=.git/ --exclude=.gitignore --include=core --delete --bwlimit=1250 /src/path/ /application/path/

あとexcludeやincludeが多くてコマンドがながくなりそうだったら

 rsync -av --exclude-from=exlude.txt --delete --bwlimit=1250 /src/path/ /application/path/
exlude.txt
# exclude
- .git/
- *.bak
- .svn/
 
# include
+ core

別ファイルで管理するのもありかな。

楽しいCIライフを送りましょう。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?