Advertisement
zefie

btrfs-list (for recovery)

Aug 23rd, 2018
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | None | 0 0
  1. #/bin/bash
  2.  
  3. Z_DISK="sdc5"
  4.  
  5. if [ ! -z "${2}" ]; then
  6.         if [ -e "/dev/${2}" ]; then
  7.                 Z_DISK="${2}"
  8.         fi
  9. fi
  10.  
  11. if [ ! -z "${1}" ]; then
  12.         if [ "${1:0:1}" == "/" ]; then
  13.                 Z_REG="${1}"
  14.         else
  15.                 Z_REG="/${1}"
  16.         fi
  17.         Z_REG=$(echo "${Z_REG}" | sed -e 's#/#(|/#g' | sed -e 's#*#(|.*#g')
  18.         Z_REG_CLOSE_COUNT=$(awk -F'(' '{print NF-1}' <<< "${Z_REG}")
  19.         Z_C=1
  20.         while [[ ${Z_C} -le ${Z_REG_CLOSE_COUNT} ]]; do
  21.                 Z_REG=$(echo "${Z_REG})")
  22.                 let Z_C=Z_C+1
  23.         done
  24.         Z_REG=$(echo "^/${Z_REG}\$"  | sed -e 's#/(|/#/(|#')
  25.         yes a | /root/tmp/btrfs-progs/btrfs restore -voD --path-regex ${Z_REG} /dev/${Z_DISK} /root/tmp/out 2>/dev/null | grep Restor | cut -d' ' -f2- | cut -d'/' -f2-
  26. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement