This commit is contained in:
Cryptoval2 2025-10-19 15:41:05 +00:00
parent 2512023079
commit 231bfd079f

View File

@ -3,8 +3,7 @@
# --------------------- Settings
# SOURCE_HOST=cloud21.cvtt.vpn
# SOURCE_ROOT_DIR=/opt/store/cvtt/md_archive/crypto
# DB_SOURCE=cloud28
# DB_SOURCE_BACKUP=cloud29
# DB_SOURCES=cloud28,cloud29
# OUTPUT_DIR=/tmp
# DATE=20250516
# RSYNC_TARGETS="cvtt@hs01.cvtt.vpn:/works/cvtt/md_archive/crypto/sim/ cvtt@cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/crypto/sim/"
@ -25,22 +24,20 @@ mkdir -p ${OUTPUT_DIR}
year=$(date -d ${DATE} +"%Y")
month=$(date -d ${DATE} +"%m")
if [ -z "${DB_SOURCES}" ]; then
echo "DB_SOURCES is empty"
exit
fi
# read the file prepare_crypto_simdata.sh
# implement the following logic.
# 1. check SourceFilePath on on SURCE_HOST for both DB_SOURCE and DB_SOURCE_BACKUP
# 2. if the file does not exist on either, exit like in line 47
# 3. if file exist on only one of them, use ti to rsync
# 4. if the file exists on both, use the one that is larger in size
IFS=',' read -r -a db_source_hosts <<< "${DB_SOURCES}"
SourceFile="${DATE}.mktdata.db.gz"
SelectedSourceHost=""
SelectedSourceFilePath=""
SelectedSourceSize=0
for db_source_host in ${DB_SOURCE} ${DB_SOURCE_BACKUP}; do
for db_source_host in "${db_source_hosts[@]}"; do
SourceDir="${SOURCE_ROOT_DIR}/${db_source_host}/${year}/${month}"
echo "SourceDir=${SourceDir}"
CandidatePath="${SourceDir}/${SourceFile}"
remote_stat_cmd="if [ -f '${CandidatePath}' ]; then stat -c %s '${CandidatePath}'; else exit 1; fi"
CandidateSize=$(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${SOURCE_HOST} "${remote_stat_cmd}" 2>/dev/null)
@ -54,8 +51,9 @@ for db_source_host in ${DB_SOURCE} ${DB_SOURCE_BACKUP}; do
fi
done
if [ -z "${SelectedSourceHost}" ]; then
echo "File ${SOURCE_HOST}:${SourceFile} NOT FOUND"
echo "File ${SourceFile} NOT FOUND on any DB_SOURCES host"
exit
fi