[symfony]
name=sample # 移動したいプロジェクト
[upserver]
user=ore # SSHで接続するユーザ名
host=upserver # SSHで接続するホスト名
dir=/var/symfony/sample # 配備先のディレクトリ
port=22
転送コマンド実行する
$ symfony sync 環境名
$ symfony sync 環境名 go(またはok)
転送したくないファイルは、config/rsync_exclude.txt に書いておく
参)Symfony.jp

symfonyで開発環境と本番環境を同期するときって

symfony sync project go
を使いますよね。

でも、同期対象を変更するたびに毎回、rsync_exclude.txtを編集するのって本気(マジ)で面倒くさいです。

そんなときはプロジェクトごとに、こんなシェルを用意しておくと非常に便利です。

/path/to/project/batch/sync.sh

#!/bin/sh

# config/properties.ini に設定しているプロジェクトに変える
LIST="target1 target2 target3"

# 以下、編集不要
cd `dirname $0`/../

if [ $# != '0' ]; then
test -f config/rsync_exclude.txt && rm config/rsync_exclude.txt
test -f config/rsync_include.txt && rm config/rsync_include.txt
test -f config/rsync.txt && rm config/rsync.txt

test -f config/rsync_exclude_$1.txt && cp config/rsync_exclude_$1.txt config/rsync_exclude.txt
test -f config/rsync_include_$1.txt && cp config/rsync_include_$1.txt config/rsync_include.txt
test -f config/rsync_$1.txt && cp config/rsync_$1.txt config/rsync.txt
fi

if test -f config/rsync.txt || test -f config/rsync_include.txt || test -f config/rsync_exclude.txt; then
for target in $LIST
do
symfony sync $target go
done
else
echo "必ず1つは設定ファイルが必要です";
fi
使い方

いつものrsync_exclude.txt, rsync_include.txt, rsync.txtをrsync_exclude_hoge.txtとかにして保存

あとは,

$ sh sync.sh hoge
で、rsync_*_hoge.txtで指定したディレクトリを対象にrsyncすることができます。

携帯サイトの開発をしていると、どうせ実機でチェックするので、PCサイト以上に細かく開発サーバーが更新されていきます。なので、このように必要なとこだけを簡単に本番かできるようにしておくのは重要です。

僕の場合、毎日の更新されていくディレクトリ用、必要な部分を書き換えるもの、全体用の3種類の設定ファイルを使ってrsyncしています。