#!/bin/sh servers="1 2 3 4 5 6" cmd='rsync -rltvp -e "ssh -l root" --delete --exclude ".svn"' srcDir="/tmp/trully/scripts" dstDir="/tmp/trully" for server in $servers do echo "Sync ${srcDir} To server-${server}:${dstDir}" eval $cmd ${srcDir} server-${server}:${dstDir} done echo "DONE!!"
rsync 參數說明
-v, --verbose increase verbosity -r, --recursive recurse into directories -l, --links copy symlinks as symlinks -p, --perms preserve permissions -t, --times preserve modification times -e, --rsh=COMMAND specify the remote shell to use --delete delete extraneous files from destination dirs -F same as --filter='dir-merge /.rsync-filter' repeated: --filter='- .rsync-filter' --exclude=PATTERN exclude files matching PATTERN
重點在 --delete 將來源端已刪除的檔案或目錄, 同步到目的端
然後 --exclude 排除 .svn 的檔案~
更詳細的指令直接下 rsync --help 查看
沒有留言:
張貼留言