天天看点

使用多台机器进行S3数据同步

使用多台机器进行S3数据同步时机器awscli环境的初始化:

---

- hosts: server1

  user: ubuntu

  sudo: yes

  gather_facts: no

  vars:

  tasks:

  - name: update apt repo

    apt: update_cache=yes

  - name: install  python-pip

    apt: name=python-pip state=present

  - name: install awscli

    pip: name=awscli

  - name: aws configure

    script: scripts/aws_configure.sh

 脚本 scripts/aws_configure.sh:  

#!/bin/sh

echo "<your access key>

<your secret key>

<region>

text

"|su   - ubuntu  -c  "aws configure"

创建syncing session:

ssh  ubuntu@<ip-address>  -C  'screen  -dmS  <session-name>  bash  -c    "aws  s3 sync s3://<bucket1>          s3://<bucket2>" '

继续阅读