1
1

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.

~/bin/をサーバ群で同期する。

Last updated at Posted at 2019-04-26

##概要
serverを巡回し、各サーバでdf; wを実行しサーバの状況を一括出力するスクリプトと同様の方法で、~/bin/を順次rsyncするスクリプト。
どこかのサーバではスクリプトを更新したのになぁ〜、でもどのサーバだったっけ?と思うことがしばしばあり、作りました。

##環境

  • サーバ群:Ubuntu, Debian, CentOS, MacOS, Raspbian

##準備
~/.syncbinに同期するホストを列挙しておく。

~/.syncbin
host1
host2
.
.
hostn

##スクリプト

~/bin/syncbin
#!/bin/bash
HOSTS=`cat ~/.syncbin`
THISHOST=`hostname`
LOG="/tmp/syncbin.log"

for TARGETHOST in $HOSTS;
do
    echo "=================================="
    echo "rsyncing $THISHOST <=> $TARGETHOST"
    echo "=================================="
    rsync -avuz ~/bin/ $TARGETHOST:~/bin/
    rsync -avuz $TARGETHOST:~/bin/ ~/bin/
done |tee $LOG
less $LOG

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?