Advertisement
zefie

btrfs-restore (for recovery)

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