#!/usr/bin/env bash thismachine=$(cat /etc/cluster_name) prodcluster=$(grep 'primary:' /lfs/h1/ops/prod/config/prodmachinefile | sed 's/primary://') devcluster=$(grep 'backup:' /lfs/h1/ops/prod/config/prodmachinefile | sed 's/backup://') dev=${devcluster:0:1}'login08' echo "$dev" if [[ ${thismachine} != ${prodcluster} ]]; then echo "This script must be run on a production machine!" exit 0 fi echo "=====> Started sync prod/dev restarts at `date`." pdy=`date +%Y%m%d` pdym1=`date --date 'now 1 day ago' +%Y%m%d` pdym2=`date --date 'now 2 day ago' +%Y%m%d` testcom=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdy} testcomm1=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdym1} testcomm2=/lfs/f2/t2o/ptmp/nwm/Zhengtao.Cui/test/com/nwm/v3.0/nwm.${pdym2} if [[ ! -d ${testcom} ]]; then exit fi ssh ${dev} "[ ! -d ${testcom} ] && mkdir -p ${testcom}" ssh ${dev} "[ ! -d ${testcomm1} ] && mkdir -p ${testcomm1}" echo "CONUS, Hawaii, Puertorico, Alaska AnA restarts!" #CONUS, Hawaii, Puertorico, Alaska domain for dir in ${testcom} ${testcomm1}; do #for dir in ${testcom}; do echo ${dir} for domain in restart restart_hawaii restart_puertorico restart_alaska; do echo "$domain" if [[ -d ${dir}/${domain}/genericRst ]]; then rsync -avz --delete --rsync-path="mkdir -p ${dir}/${domain}/genericRst/ && rsync" ${dir}/${domain}/genericRst/ ${dev}:${dir}/${domain}/genericRst/ fi if [[ -d ${dir}/${domain}_no_da/genericRst ]]; then rsync -avz --delete --rsync-path="mkdir -p ${dir}/${domain}_no_da/genericRst/ && rsync" ${dir}/${domain}_no_da/genericRst/ ${dev}:${dir}/${domain}_no_da/genericRst/ fi if [[ -d ${dir}/${domain}/nwm.rst.21 ]]; then rsync -avz --delete --rsync-path="mkdir -p ${dir}/${domain}/nwm.rst.21/ && rsync" ${dir}/${domain}/nwm.rst.21/ ${dev}:${dir}/${domain}/nwm.rst.21/ fi done done #AnA long echo "CONUS, AnA long restarts!" #for dir in ${testcom} ${testcomm1}; do for dir in ${testcom}; do if [[ -d ${dir}/restart_long ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_long && rsync" \ ${dir}/restart_long/ ${dev}:${dir}/restart_long/ fi if [[ -d ${dir}/restart_long_no_da ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_long_no_da && rsync" \ ${dir}/restart_long_no_da/ ${dev}:${dir}/restart_long_no_da/ fi done echo "AnA extended restarts!" #for dir in ${testcom} ${testcomm1}; do for dir in ${testcom}; do if [[ -d ${dir}/restart_extend ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_extend && rsync" ${dir}/restart_extend/ ${dev}:${dir}/restart_extend/ fi if [[ -d ${dir}/restart_extend_no_da ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_extend_no_da && rsync" ${dir}/restart_extend_no_da/ ${dev}:${dir}/restart_extend_no_da/ fi done #Forecast restarts echo "All forecast restartss!" #for dir in ${testcom} ${testcomm1}; do for dir in ${testcom}; do for restart in restart_forecast \ restart_long_forecast \ restart_alaska_forecast \ restart_hawaii_forecast \ restart_puertorico_forecast; do if [[ -d ${dir}/${restart} ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/${restart} && rsync" \ ${dir}/${restart}/ ${dev}:${dir}/${restart}/ fi done done echo "All coastal restartss!" #coastal restarts #for dir in ${testcom} ${testcomm1}; do for dir in ${testcom}; do if [[ -d ${dir}/restart_coastal ]]; then rsync -avz --rsync-path="mkdir -p ${dir}/restart_coastal && rsync" \ ${dir}/restart_coastal/ ${dev}:${dir}/restart_coastal/ fi done echo "=====> Done sync prod/dev restarts at `date`."