LoginSignup
4
2

More than 5 years have passed since last update.

unisonでローカルとサーバをお手軽に同期する

Last updated at Posted at 2017-09-22

はじめに

ローカルとサーバのディレクトリを同期する必要があったので、今回unisonを使ってみました。
予想以上にunisonのバージョンを揃えたりと面倒だったのでインストール手順を残しておきます。
基本的に上からコピペすれば動くと思います。

ローカル

unisonのインストール
$ brew install unison
# プロジェクトを作成
/Users/user.name/.unison/project.prf

下記参考に諸々書き換える(IPはhostでいける)
これがどこのサーバと同期するか、何を同期するかの設定ファイルとなります。

# リモートのディレクトリ
root = ssh://project.com//var/www/project
# ローカルのディレクトリ
root = /Users/user.name/Desktop/project


ignore = Path vendor
ignore = Name {tmp,log}
auto = true
times = true
prefer = newer

サーバ

結構長い
コケるけど無視

curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash

インストールが終わるとocamlbrewというディレクトリが出来ます。

.bashrcに下記をコピペ(ocamlbrewのバージョンは合わせてください)

.bashrc
__ocaml_path__="$HOME/ocamlbrew/ocaml-4.03.0" # ~/ocamlbrewをlsしてみて適切なバージョン番号に置き換えてください
PATH="$__ocaml_path__/bin:$PATH"
export OPAMROOT="$__ocaml_path__/.opam"
source "$OPAMROOT/opam-init/init.bash" > /dev/null 2> /dev/null || true

パスを通す

source ~/.bashrc

インストール

ここも少し長い

opam switch 4.03.0

インストール

opam install oasis utop Batteries ocamlscript
sudo yum install ocaml ocaml-camlp4-devel ctags ctags-etags

ファイルをダウンロード&移す

サーバにインストールするために、パッケージをダウンロードします。
ローカルとサーバのunisonのバージョンを合わせる必要があるので、ローカルにインストールしたバージョンをダウンロード
してください。

サイト http://www.seas.upenn.edu/~bcpierce/unison//download/releases/

macで解答

解凍したファイルをサーバにアップロード

scp -r /Users/shoichi/Downloads/src project.com:/home/webmaster

アップロードしたファイルに移動してビルド

make
# ビルドが終わったらこのコマンドをインストールしたら叩く
sudo cp -v unison /usr/bin/

これでセットアップが完了しました。
あとはローカルに戻って下記を実行して、同期していきましょう。

実行

unison project -repeat watch

以上です。

参考

http://qiita.com/yuya_presto/items/f35f556770196f964810
https://plus.google.com/103080563170453474101/posts/ZMBytWVkhTn
https://www.digitalocean.com/community/questions/install-unison-in-centos-7

4
2
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
4
2