-
Notifications
You must be signed in to change notification settings - Fork 1
working file for data backup #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
| storedir=/store/cpnr-data/RENE/Data/Data | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 대부분 경우 bash에서 변수는 대문자로 적어요. storedir -> STOREDIR |
||
|
|
||
| nPRD=0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nPRD -> NPRD |
||
|
|
||
| #for run in 1000 ;do | ||
| for run in {475..2223..1};do | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. run -> RUN
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 하면 특정 run number에 대해서만 돌 것 같은데 일반화 할 수 있나요? |
||
| 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` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NPRD 변수가 이 loop안에서 바뀌지만 사용되지는 않는 것 같아요. 의도한 건가요?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 갯수만 세는 거라면 ls -l 에서 -l 옵션은 빼는 게 좋아요. newline을 붙이는 걸 명시하고 싶다면 -1 (숫자1) 을 넣으세요. -l 을 하게 되면 formatting을 하기 때문에 느려져요. |
||
| fi | ||
|
|
||
| done | ||
|
|
||
| dirname=$storedir/RAW/$run_str | ||
| nFADC=`ls -l $dirname/FADC* |wc -l` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ls -l 에서 -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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/bin/bash | ||
|
|
||
| #if [ $# -ne 2 ]; then | ||
| # echo "usage: $0 <folderA> <folderB>" | ||
| # exit 1 | ||
| #fi | ||
|
|
||
| dirname_1=Data/RAW | ||
| dirname_2=Data_ssd/RAW | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dirname_1 -> DIRNAME1, dirname_2 -> DIRNAME2 쪽이 나음. |
||
|
|
||
|
|
||
| for run in {1..2300..1} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 런넘버 기준 일반화 가능한지. |
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <DIR1> <DIR2>" | ||
| 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." | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파일명 짓는 방식은 동사->명사 식이 읽기 좋아요. check_presence_of_PRDfile.sh 또는 check_PRDfile_presence