Shell exercises-Bulk Sync code

Source: Internet
Author: User

The requirements background is:

A business, with 3 servers (A,B,C) Doing load balancing, because the scale is too small to use a professional automated maintenance tool at this time. When there is a new requirement, the development colleague changes the code to upload the change to one of the server A. But the other 2 servers also need to make the same changes.

Write a shell script that synchronizes the change code on the a server to B and C.

Where you need to consider directories that do not need to be synchronized (if you have TMP, upload, logs, caches)



#!/bin/bashecho "The script will synchronize the/data/wwwroot/www.aaa.com directory on the A machine to the b,c machine"; Read-p "Do you want to continue? (y|n) "RS () {rsync-azp--exclude logs--exclude upload--exclude caches--exclude tmp www.aaa.com/$1:/data /wwwroot/www.aaa.com/}if [$REPLY = = ' y '-o $REPLY = = ' Y ']then echo "About to sync ..." Sleep 2 cd/data/wwwroot/rs B Machine IP rs C machine IP echo "is completed synchronously. "Elif [$REPLY = = ' n '-o $REPLY = = ' n ']then exit 1else echo" Please enter the letter Y or n "fi


This article is from the It Dick thread blog, so be sure to keep this source http://68686789.blog.51cto.com/10438688/1980112

Shell exercises-Bulk Sync code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.