summaryrefslogtreecommitdiffstats
path: root/scripts/disaster/walker.sh
blob: 021110596bd94d123fe72ba185464a13828a4d23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /bin/bash


#find /mnt/provision/kaas/adei -type f -print0 | xargs -0 -I{} -n 1  sh -c ' dd if="$1" of=/dev/null bs=1M status=none  || true; sleep .5' _ "{}"

#find /mnt/ands/glusterfs/brick-provision/kaas/bora -type f -size 0 -print0 | \
#while IFS= read -r -d '' f; do
#  echo "Remvoing $f"
#  setfattr -x trusted.glusterfs.mdata "$f" 2>/dev/null || true
#  for a in $(getfattr -d -m trusted.afr -e hex "$f" 2>/dev/null | awk -F= '/trusted\.afr/{print $1}'); do
#      setfattr -x "$a" "$f" 2>/dev/null || true
#  done
#done

#echo 3 | sudo tee /proc/sys/vm/drop_caches
#find /mnt/wave/ -type f -print0 | xargs -0 -I{} -n 1 -P 8  sh -c '
#        f="$1"
#        dd if="$f" of=/dev/null bs=1M status=none  || true;
#        sz=$(stat -c%s "$f" 2>/dev/null || echo 0)
#        echo "$f $sz"
#        if [ "$sz" -eq 0 ]; then
#          # give gluster a breath and try again, like you do manually
#          sleep 0.5
#          dd if="$f" of=/dev/null bs=1M status=none 2>/dev/null || true
##          sz=$(stat -c%s "$f" 2>/dev/null || echo 0)
#        fi
#    ' _ "{}"

#find /mnt/datastore/services/gogs -type f -print0 | xargs -0 -n200 -P16 rm -
#find /mnt/datastore/services/gogs -depth -type d -empty -delete
#find /mnt/datastore/services/gogs/repositories -maxdepth 1 -mindepth 1 -type d -print0  | xargs -0 -I{} -n1 -P200 sh -c 'rm -rf "$1"' _ "{}"


#echo 3 | sudo tee /proc/sys/vm/drop_caches
#find /mnt/ands/glusterfs/brick-katrin_data -name .glusterfs -prune -o -type f -size 0 -print0 | xargs -0 -I{} -n 1 -P 8  sh -c '
#        fbrick="$1"
#        brick_prefix="/mnt/ands/glusterfs/brick-katrin_data"
#        mount_prefix="/mnt/katrin"
#        fmount="${fbrick/#$brick_prefix/$mount_prefix}"
#        dd if="$fmount" of=/dev/null bs=1M status=none  || true;
#        sz=$(stat -c%s "$fbrick" 2>/dev/null || echo 0)
#        echo "$fmount $sz"
#        if [ "$sz" -eq 0 ]; then
#          # give gluster a breath and try again, like you do manually
#          sleep 0.5
#          dd if="$fmount" of=/dev/null bs=1M status=none 2>/dev/null || true
##          sz=$(stat -c%s "$fbrick" 2>/dev/null || echo 0)
#        fi
#    ' _ "{}"
#

echo 3 | sudo tee /proc/sys/vm/drop_caches
find /mnt/ands/glusterfs/brick-katrin_data -name .glusterfs -prune -o -type f -print0 | xargs -0 -I{} -n 1 -P 8  sh -c '
        fbrick="$1"
        mount_prefix="/mnt/katrin"
        brick_prefix="/mnt/ands/glusterfs/brick-katrin_data"
        fmount="${fbrick/#$brick_prefix/$mount_prefix}"
        szbrick=$(stat -c%s "$fbrick" 2>/dev/null || echo 0)
        szmount=$(stat -c%s "$fmount" 2>/dev/null || echo 0)
        if [ $szbrick -ne $szmount ]; then
          dd if="$fmount" of=/dev/null bs=1M status=none 2>/dev/null || true
          sz=$(stat -c%s "$fbrick" 2>/dev/null || echo 0)
          while [ $sz -ne $szmount ]; do
                echo "* $fmount $szmount $szbrick => $sz"
                sleep 1
                dd if="$fmount" of=/dev/null bs=1M status=none 2>/dev/null || true
                sz=$(stat -c%s "$fbrick" 2>/dev/null || echo 0)
          done
          echo "$fmount $szmount $szbrick => $sz"
        fi
    ' _ "{}"