diff --git a/work_for_backup/PRDfile_presence_check.sh b/work_for_backup/PRDfile_presence_check.sh new file mode 100755 index 0000000..1f636d2 --- /dev/null +++ b/work_for_backup/PRDfile_presence_check.sh @@ -0,0 +1,45 @@ +#!/bin/bash + + +storedir=/store/cpnr-data/RENE/Data/Data + +nPRD=0 + +#for run in 1000 ;do +for run in {475..2223..1};do + run_str=$(printf "%06d" "$run") + found=0 + if [ -d "${storedir}/RAW/${run_str}" ]; then + #echo $run_str + + if [ ! -d "${storedir}/RAW/${run_str}/PRD" ]; then + mkdir -p ${storedir}/RAW/${run_str}/PRD + mkdir -p ${storedir}/RAW/${run_str}/Merged + mkdir -p ${storedir}/RAW/${run_str}/PNG + fi + + for file in ${storedir}/RAW/${run_str}/PRD/*; do + + if [ -f "$file" ]; then + found=1 + + nPRD=`ls -l $dirname/PRD/* |wc -l` + fi + + done + + dirname=$storedir/RAW/$run_str + nFADC=`ls -l $dirname/FADC* |wc -l` + + if [ $found -eq 0 ]; then + #echo Data/RAW/${run_str}/PRD/ + echo ${run_str} + else + if [ $nFADC -gt $found ]; then # nfound > nPRD + #echo Data/RAW/${run_str}/PRD/ + echo ${run_str} + fi + fi + + fi +done diff --git a/work_for_backup/compare_folders.sh b/work_for_backup/compare_folders.sh new file mode 100755 index 0000000..a842174 --- /dev/null +++ b/work_for_backup/compare_folders.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +#if [ $# -ne 2 ]; then +# echo "usage: $0 " +# exit 1 +#fi + +dirname_1=Data/RAW +dirname_2=Data_ssd/RAW + + +for run in {1..2300..1} +do + + #DIR_A="$1" + #DIR_B="$2" + DIR_A=${dirname_1}/${run} + DIR_B=${dirname_2}/${run} + + + # tmp file + FILES_A=$(mktemp) + FILES_B=$(mktemp) + + find "$DIR_A" -type f | sed "s|^$DIR_A/||" | sort > "$FILES_A" + find "$DIR_B" -type f | sed "s|^$DIR_B/||" | sort > "$FILES_B" + + #echo "same file:" + #comm -12 "$FILES_A" "$FILES_B" + #echo + + echo "only in ${DIR_A}:" + comm -23 "$FILES_A" "$FILES_B" + echo + + echo "only in ${DIR_B}:" + comm -13 "$FILES_A" "$FILES_B" + echo + + # remove tmp file + rm -f "$FILES_A" "$FILES_B" + +done diff --git a/work_for_backup/count_FADC_SADC.sh b/work_for_backup/count_FADC_SADC.sh new file mode 100755 index 0000000..06310ca --- /dev/null +++ b/work_for_backup/count_FADC_SADC.sh @@ -0,0 +1,34 @@ +#!/bin/bash + + + +storedir=/store/cpnr-data/RENE/Data/Data + +echo "runN,nFADC,nSADC" + +for run in {1..2223..1};do + run_str=$(printf "%06d" "$run") + + #echo "$run_str" + + dirname=$storedir/RAW/$run_str + + if [ -d "$storedir/RAW/${run_str}" ]; then + nn=`ls -l $storedir/RAW/${run_str} |wc -l` + if [ ${nn} -ne 3 ];then + nFADC=`ls -l $dirname/FADC* |wc -l` + nSADC=`ls -l $dirname/SADC* |wc -l` + echo "${run_str},${nFADC},${nSADC}" + fi + + if [ ${nn} -eq 3 ];then + echo "${run_str},0,0" + fi + fi + + if [ ! -d "$storedir/RAW/${run_str}" ]; then + echo "${run_str},0,0" + fi + +done + diff --git a/work_for_backup/delete_merged_file.sh b/work_for_backup/delete_merged_file.sh new file mode 100755 index 0000000..ad2d1fd --- /dev/null +++ b/work_for_backup/delete_merged_file.sh @@ -0,0 +1,9 @@ +for runN in {1..2101..1};do + RunStr=$(seq -f "%06g" ${runN} ${runN}) + if [ -d "Data/RAW/${RunStr}" ];then + echo "remove ${RunStr}/Merged/*.root.*" + rm Data/RAW/${RunStr}/Merged/*.root.* + fi +done + + diff --git a/work_for_backup/file_integrity_check.sh b/work_for_backup/file_integrity_check.sh new file mode 100755 index 0000000..35e2245 --- /dev/null +++ b/work_for_backup/file_integrity_check.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Usage: ./ultimate_compare.sh /path/to/dir1 /path/to/dir2 +DIR1="$1" +DIR2="$2" + +if [[ ! -d "$DIR1" || ! -d "$DIR2" ]]; then + echo "Error: Two valid directories must be provided." + echo "Usage: $0 " + exit 1 +fi + +echo "Comparing:" +echo " DIR1 = $DIR1" +echo " DIR2 = $DIR2" + +echo "" +echo "Step 1: Directory structure comparison..." +STRUCTURE_DIFF=$(diff <(cd "$DIR1" && find . | sort) <(cd "$DIR2" && find . | sort)) +if [[ -n "$STRUCTURE_DIFF" ]]; then + echo "[!] Directory structure differs:" + echo "$STRUCTURE_DIFF" +else + echo "[OK] Structures match." +fi + +echo "" +echo "Step 2: File content comparison using sha256sum..." +cd "$DIR1" +find . -type f | while read -r file; do + #echo "$DIR2/$file" + + + if [[ -f "$DIR2/$file" ]]; then + sum1=$(sha256sum "$file" | awk '{print $1}') + sum2=$(sha256sum "$DIR2/$file" | awk '{print $1}') + if [[ "$sum1" != "$sum2" ]]; then + echo "[!] Content mismatch: $file" + fi + else + echo "[!] Missing in DIR2: $file" + fi +done +cd - >/dev/null + +echo "" +echo "Step 3: Permission and timestamp comparison..." +cd "$DIR1" +find . -type f | while read -r file; do + if [[ -f "$DIR2/$file" ]]; then + perm1=$(stat -c "%a" "$file") + perm2=$(stat -c "%a" "$DIR2/$file") + if [[ "$perm1" != "$perm2" ]]; then + echo "[!] Permission mismatch: $file ($perm1 vs $perm2)" + fi + + time1=$(stat -c "%Y" "$file") + time2=$(stat -c "%Y" "$DIR2/$file") + if [[ "$time1" != "$time2" ]]; then + echo "[!] Timestamp mismatch: $file" + fi + fi +done +cd - >/dev/null + +echo "" +echo "Step 4: Final deep check using rsync checksum mode..." +rsync -nrc "$DIR1/" "$DIR2/" > rsync_diff.log +if [[ -s rsync_diff.log ]]; then + echo "[!] rsync reports differences:" + cat rsync_diff.log +else + echo "[OK] rsync checksum check passed. No differences found." +fi + +echo "" +echo "Full comparison complete." + diff --git a/work_for_backup/move_Dir2Dir.sh b/work_for_backup/move_Dir2Dir.sh new file mode 100755 index 0000000..7aa19db --- /dev/null +++ b/work_for_backup/move_Dir2Dir.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +SRC_BASE="Data_ssd/RAW" +DST_BASE="Data/RAW" + +for SRC_DIR in "${SRC_BASE}"/*; do + + echo "SRC DIR : $SRC_DIR" + + runNumber=$(basename "$SRC_DIR") + DST_DIR="${DST_BASE}/${runNumber}" + + if [ ! -d "$DST_DIR" ]; then + mkdir "$DST_DIR" + echo "Created directory: $DST_DIR" + fi + + rsync -av --ignore-existing \ + "${SRC_DIR}/" \ + "${DST_DIR}/" +done +