Скрипт который раскидывает бэкапы по папкам s3

#!/bin/bash
#set -x
H=/home/ubuntu/s3

#echo $1

for file in `/usr/bin/aws s3 ls $1/`
do
if [ "$(echo $file | grep ".gz" | grep "sugarcrm")" ];
then
        monthly=$(echo $file | awk -F"-" '{print $3}')
        year=20$(echo $file | awk -F"-" '{print $2}')
#        echo "$year/$monthly"
        mkdir -p $H/$year/$monthly
        touch $H/$year/$monthly/auto
        aws s3 sync $H $2/daily/scrm_prod_79x/
        rm -f $H/$year/$monthly/auto
        echo $file
        aws s3 mv $1/$file $2/daily/scrm_prod_79x/$year/$monthly/$file
        aws s3 rm $2/daily/scrm_prod_79x/$year/$monthly/auto
fi
done

 

Bash

Related Articles

0 Comment

Leave a Comment

Ваш адрес email не будет опубликован.