btrfs-recover-scripts
btrfs-recover-scripts copied to clipboard
BTRFS Recover scripts on Synology DS1812+
Hi Quentin McGaw,
I had an issues in running the script so I had to modify line 22 by adding $
in 2 locations as follows:
TXID_BLOCKID=$(paste <$(echo "$TRANSIDS") <$(echo "$BLOCKNUMBERS"))
The script now looks like this with my device path settings:
#!/bin/sh
printf "RESTORE SCRIPT\n"
DISK_TO_RECOVER=/dev/vg1004/lv
RESTORE_PATH=/volume1/restore1/files
RECENT_FILEPATH=/volume7
# Find roots with transaction id
printf "Finding all roots..."
ROOTS_RAW=$(btrfs-find-root "$DISK_TO_RECOVER" 2> /dev/null | grep 'Well')
status=$?
if [ $status != 0 ]; then
printf "FAILURE ($status)\n"
return 1
fi
printf "$(echo "$ROOTS_RAW" | wc -l) found\n"
# Sort roots block numbers by transaction id
BLOCKNUMBERS=$(echo "$ROOTS_RAW" | grep -oE 'Well block [0-9]*' | grep -oE '[0-9]*')
TRANSIDS=$(echo "$ROOTS_RAW" | grep -oE '\(gen: [0-9]*' | grep -oE '[0-9]*')
TXID_BLOCKID=$(paste <$(echo "$TRANSIDS") <$(echo "$BLOCKNUMBERS"))
SORTED_ROOTS=$(echo "$TXID_BLOCKID" | sort -rn | uniq | cut -f 2)
printf "Searching for $RECENT_FILEPATH in the roots block numbers...\n"
printf "Trying roots block numbers: "
FIRST_VALID_ROOT=
for BLOCK in $SORTED_ROOTS; do
printf "$BLOCK ";
if [ "$(btrfs restore -ivD -t "$BLOCK" "$DISK_TO_RECOVER" /tmp 2> /dev/null | grep "$RECENT_FILEPATH")" != "" ]; then
if [ "$FIRST_VALID_ROOT" = "" ]; then FIRST_VALID_ROOT="$BLOCK"; fi;
printf "\nRoot block number $BLOCK contains $RECENT_FILEPATH - ";
read -p "recover from this root block number? (y/n) [y]: " -r -n 1;
echo;
if [ "$REPLY" != "y" ]; then
printf "Continuing... trying roots block numbers: ";
else
printf "Recovering $DISK_TO_RECOVER to $RESTORE_PATH with root block number $BLOCK...\n";
btrfs restore -iv -t "$BLOCK" "$DISK_TO_RECOVER" "$RESTORE_PATH" 2>&1 | tee btrfs-restore.log;
status=$?;
printf "\nFinished\nYou can see the log in btrfs-restore.log\n";
return $status;
fi;
fi;
done;
printf "All roots blocks numbers have been tried, recovering with first valid root block number $FIRST_VALID_ROOT\n"
btrfs restore -iv -t "$FIRST_VALID_ROOT" "$DISK_TO_RECOVER" "$RESTORE_PATH" 2>&1 | tee btrfs-restore.log
status=$?;
printf "\nFinished\nYou can see the log in btrfs-restore.log\n"
return $status;
now the script runs but it gives the following error:
RESTORE SCRIPT
Finding all roots...10 found
./restore.sh: line 22: $(echo "$TRANSIDS"): No such file or directory
Searching for /volume7 in the roots block numbers...
Trying roots block numbers: All roots blocks numbers have been tried, recovering with first valid root block number
Restoring /volume1/restore1/files/@syno
Restoring /volume1/restore1/files/@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@eaDir/snaptree.bin
Done searching /@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@iSCSI/tmp
Reached the end of the tree searching the directory
Done searching /@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@tmp
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20465.1570269133.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20465.1570269136.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20465.1570269137.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20465.1570269138.rss
Done searching /@syno/@tmp/synodl_rss
Done searching /@syno/@tmp
Done searching /@syno
Reached the end of the tree searching the directory
Finished
You can see the log in btrfs-restore.log
./restore.sh: line 49: return: can only `return' from a function or sourced script
Thanks for the email reply. However, I did not understand the modifications that you want me to try and post results.
Hi there,
I had an issues in running the script so I had to modify line 22 by adding $ in 2 locations as follows:
TXID_BLOCKID=$(paste <$(echo "$TRANSIDS") <$(echo "$BLOCKNUMBERS"))
The line is exactly as it was before (link)
TXID_BLOCKID=$(paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS"))
So I don't understand what you changed?
Thanks for the email reply. However, I did not understand the modifications that you want me to try and post results.
Please open a terminal and enter the following command:
sudo btrfs-find-root /dev/vg1004/lv
And report back the logs here.
Also note I have updated the scripts, you can try again with the restore.sh script.
admin@DISKSTATION:/volume1/scripts$ sudo ./unmount.sh
UNMOUNT VOLUME SCRIPT
Unmounting /dev/vg1004/lv ...SUCCESS
admin@DISKSTATION:/volume1/scripts$ sudo ./restore1.sh
RESTORE SCRIPT
Finding all roots...FAILURE (1)
admin@DISKSTATION:/volume1/scripts$ sudo btrfs-find-root /dev/vg1004/lv
Superblock thinks the generation is 14822
Superblock thinks the level is 0
Found tree root at 29999104 gen 14822 level 0
Well block 29949952(gen: 14821 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
Well block 29868032(gen: 14820 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
Well block 29786112(gen: 14819 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
Well block 29589504(gen: 14818 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
Well block 29474816(gen: 14817 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
Well block 29392896(gen: 14816 level: 0) seems good, but generation/level doesn't match, want gen: 14822 level: 0
The restore script should not fail at the Finding all roots
level...
In a terminal, try line by line and stop as soon as one fails:
ROOTS_RAW=`btrfs-find-root "$DISK_TO_RECOVER" 2> /dev/null | grep 'Well'`
echo "Exit code: $?"
echo "$ROOTS_RAW"
echo
BLOCKNUMBERS=`echo "$ROOTS_RAW" | grep -oE 'Well block [0-9]*' | grep -oE '[0-9]*'`
echo "$BLOCKNUMBERS"
echo
TRANSIDS=`echo "$ROOTS_RAW" | grep -oE '\(gen: [0-9]*' | grep -oE '[0-9]*'`
echo "$TRANSIDS"
echo
TXID_BLOCKID=`paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")`
echo "$TXID_BLOCKID"
admin@DISKSTATION: $~ROOTS_RAW=`btrfs-find-root "$DISK_TO_RECOVER" 2> /dev/null | grep 'Well'`
admin@DISKSTATION:~$ echo "Exit code: $?"
Exit code: 1
admin@DISKSTATION:~$ echo "$ROOTS_RAW"
admin@DISKSTATION:~$ echo
admin@DISKSTATION:~$ BLOCKNUMBERS=`echo "$ROOTS_RAW" | grep -oE 'Well block [0-9]*' | grep -oE '[0-9]*'`
admin@DISKSTATION:~$ echo "$BLOCKNUMBERS"
admin@DISKSTATION:~$ echo
admin@DISKSTATION:~$ TRANSIDS=`echo "$ROOTS_RAW" | grep -oE '\(gen: [0-9]*' | grep -oE '[0-9]*'`
admin@DISKSTATION:~$ echo "$TRANSIDS"
admin@DISKSTATION:~$ echo
admin@DISKSTATION:~$ TXID_BLOCKID=`paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")`
-sh: command substitution: line 1: syntax error near unexpected token `('
-sh: command substitution: line 1: `paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")'
admin@DISKSTATION:~$
Did you set DISK_TO_RECOVER=/dev/vg1004/lv
before running any of these commands?
Also what shell are you using? You can find that with echo $SHELL
mine is /bin/ash
I have repeated it with "DISK_TO_RECOVER=/dev/vg1004/lv" and the results are below. My shell is /bin/sh
admin@DISKSTATION:~$ echo $SHELL
/bin/sh
admin@DISKSTATION:~$ DISK_TO_RECOVER=/dev/vg1004/lv
admin@DISKSTATION:~$ ROOTS_RAW=`btrfs-find-root "$DISK_TO_RECOVER" 2> /dev/null | grep 'Well'`
admin@DISKSTATION:~$ echo "Exit code: $?"
Exit code: 1
admin@DISKSTATION:~$ echo "$ROOTS_RAW"
admin@DISKSTATION:~$ BLOCKNUMBERS=`echo "$ROOTS_RAW" | grep -oE 'Well block [0-9]*' | grep -oE '[0-9]*'`
admin@DISKSTATION:~$ echo "$BLOCKNUMBERS"
admin@DISKSTATION:~$ echo
admin@DISKSTATION:~$ TRANSIDS=`echo "$ROOTS_RAW" | grep -oE '\(gen: [0-9]*' | grep -oE '[0-9]*'`
admin@DISKSTATION:~$ echo "$TRANSIDS"
admin@DISKSTATION:~$ echo
admin@DISKSTATION:~$ TXID_BLOCKID=`paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")`
-sh: command substitution: line 1: syntax error near unexpected token `('
-sh: command substitution: line 1: `paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")'
Oh my bad, the script was trying to /bin/sh
which does not support the command paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")
with weird paste redirections.
I have updated the script here to use bash
instead of sh
. Maybe try it like that?
The results of the updated script:
admin@DISKSTATION:/volume1/scripts$ sudo ./restore2.sh
RESTORE SCRIPT
Finding all roots...6 found
Searching for /volume7 in the roots block numbers...
Trying roots block numbers: 29949952 ./restore2.sh: line 29: [: !=: unary operator expected
29868032 ./restore2.sh: line 29: [: !=: unary operator expected
29786112 ./restore2.sh: line 29: [: !=: unary operator expected
29589504 ./restore2.sh: line 29: [: !=: unary operator expected
29474816 ./restore2.sh: line 29: [: !=: unary operator expected
29392896 ./restore2.sh: line 29: [: !=: unary operator expected
All roots blocks numbers have been tried, recovering with first valid root block number
Restoring /volume1/restore1/files/@syno
Restoring /volume1/restore1/files/@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@eaDir/snaptree.bin
Done searching /@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@iSCSI/tmp
Reached the end of the tree searching the directory
Done searching /@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@tmp
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356122.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356125.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356126.rss
Done searching /@syno/@tmp/synodl_rss
Done searching /@syno/@tmp
Done searching /@syno
Reached the end of the tree searching the directory
Finished with status 0
You can see the log in btrfs-restore.log
Oops went too quick at changing, please try again with new fixes, new script
the results for the new script:
admin@DISKSTATION:/volume1/scripts$ sudo ./restore2.sh
./restore2.sh: line 13: syntax error near unexpected token `('
./restore2.sh: line 13: ` printf "FAILURE ($status)\n"'
Uh ok strange, please try with this script?
#!/bin/ash
printf "RESTORE SCRIPT\n"
DISK_TO_RECOVER=/dev/mapper/cachedev_0
RESTORE_PATH=/volumeUSB1/usbshare
RECENT_FILEPATH=/mypath/recentfile.txt
# Find roots with transaction id
printf "Finding all roots..."
ROOTS_RAW=`btrfs-find-root "$DISK_TO_RECOVER" 2> /dev/null | grep 'Well'`
status=$?
if [[ $status != 0 ]]; then
printf "FAILURE ($status)\n"
exit 1
fi
printf "$(echo "$ROOTS_RAW" | wc -l) found\n"
# Sort roots block numbers by transaction id
BLOCKNUMBERS=`echo "$ROOTS_RAW" | grep -oE 'Well block [0-9]*' | grep -oE '[0-9]*'`
TRANSIDS=`echo "$ROOTS_RAW" | grep -oE '\(gen: [0-9]*' | grep -oE '[0-9]*'`
TXID_BLOCKID=`paste <(echo "$TRANSIDS") <(echo "$BLOCKNUMBERS")`
SORTED_ROOTS=`echo "$TXID_BLOCKID" | sort -rn | uniq | cut -f 2`
printf "Searching for $RECENT_FILEPATH in the roots block numbers...\n"
printf "Trying roots block numbers: "
FIRST_VALID_ROOT=
for BLOCK in $SORTED_ROOTS; do
printf "$BLOCK ";
if [[ `btrfs restore -ivD -t "$BLOCK" "$DISK_TO_RECOVER" /tmp 2> /dev/null | grep "$RECENT_FILEPATH"` != "" ]]; then
[[ "$FIRST_VALID_ROOT" = "" ]] && FIRST_VALID_ROOT="$BLOCK";
printf "\nRoot block number $BLOCK contains $RECENT_FILEPATH - ";
read -p "recover from this root block number? (y/n) [y]: " -r -n 1;
echo;
if [[ "$REPLY" != "y" ]]; then
printf "Continuing... trying roots block numbers: ";
else
printf "Recovering $DISK_TO_RECOVER to $RESTORE_PATH with root block number $BLOCK...\n";
btrfs restore -iv -t "$BLOCK" "$DISK_TO_RECOVER" "$RESTORE_PATH" 2>&1 | tee btrfs-restore.log;
status=$?;
printf "\nFinished with status $status\nYou can see the log in btrfs-restore.log\n";
exit $status
fi;
fi;
done;
printf "All roots blocks numbers have been tried, recovering with first valid root block number $FIRST_VALID_ROOT\n"
btrfs restore -iv -t "$FIRST_VALID_ROOT" "$DISK_TO_RECOVER" "$RESTORE_PATH" 2>&1 | tee btrfs-restore.log
printf "\nFinished with status $status\nYou can see the log in btrfs-restore.log\n"
exit $status
output:
admin@DISKSTATION:/volume1/scripts$ sudo ./restore3.sh
RESTORE SCRIPT
Finding all roots...6 found
Searching for /volume7 in the roots block numbers...
Trying roots block numbers: 29949952 ./restore3.sh: line 29: [: !=: unary operator expected
29868032 ./restore3.sh: line 29: [: !=: unary operator expected
29786112 ./restore3.sh: line 29: [: !=: unary operator expected
29589504 ./restore3.sh: line 29: [: !=: unary operator expected
29474816 ./restore3.sh: line 29: [: !=: unary operator expected
29392896 ./restore3.sh: line 29: [: !=: unary operator expected
All roots blocks numbers have been tried, recovering with first valid root block number
Restoring /volume1/restore1/files/@syno
Restoring /volume1/restore1/files/@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@eaDir/snaptree.bin
Done searching /@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@iSCSI/tmp
Reached the end of the tree searching the directory
Done searching /@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@tmp
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356122.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356125.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356126.rss
Done searching /@syno/@tmp/synodl_rss
Done searching /@syno/@tmp
Done searching /@syno
Reached the end of the tree searching the directory
Finished with status 0
You can see the log in btrfs-restore.log
Are you sure there is /bin/ash
at the top?
If yes, try again the script above I have updated it
It seems now running without errors. However, it did not recovering the deleted folder. the output is below:
admin@DISKSTATION:/volume1/scripts$ sudo ./restore3.sh
RESTORE SCRIPT
Finding all roots...6 found
Searching for /volume7 in the roots block numbers...
Trying roots block numbers: 29949952 29868032 29786112 29589504 29474816 29392896 All roots blocks numbers have been tried, recovering with first valid root block number
Restoring /volume1/restore1/files/@syno
Restoring /volume1/restore1/files/@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@eaDir/snaptree.bin
Done searching /@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@iSCSI/tmp
Reached the end of the tree searching the directory
Done searching /@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@tmp
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356122.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356125.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20403.1570356126.rss
Done searching /@syno/@tmp/synodl_rss
Done searching /@syno/@tmp
Done searching /@syno
Reached the end of the tree searching the directory
Finished with status 0
You can see the log in btrfs-restore.log
Are you trying to restore volume 1 or 7?
Because there is the strange line
Searching for /volume7 in the roots block numbers
I am trying to restore a deleted folder in volume7
Maybe that's another device than /dev/vg1004/lv
?
Try checking btrfs filesystem show
in your terminal
admin@DISKSTATION:/volume7$ btrfs filesystem show
admin@DISKSTATION:/volume7$ sudo btrfs filesystem show
Password:
Label: '2017.12.02-10:45:56 v15217' uuid: dc7f7ccf-7bc2-4d37-9362-ed191ef865c5
Total devices 1 FS bytes used 208.00KiB
devid 1 size 5.45TiB used 13.02GiB path /dev/mapper/vg1004-lv
Try btrfs subvolume list -a /dev/mapper/vg1004-lv
, you might need to remount your file system to do that however. See https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-subvolume
EDIT: Updated btrfs command
this command worked only as:
sudo btrfs subvolume list -a /volume7
the other options gave me errors
admin@DISKSTATION:~$ sudo btrfs subvolume list -a /volume7
ID 257 gen 14837 top level 5 path <FS_TREE>/@syno
ID 359 gen 14834 top level 257 path @syno/@iSCSI
admin@DISKSTATION:~$ sudo btrfs subvolume list -a /dev/mapper/vg1004-lv
ERROR: not a btrfs filesystem: /dev/mapper/vg1004-lv
ERROR: can't access '/dev/mapper/vg1004-lv'
admin@DISKSTATION:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/md0 2385528 1331568 935176 59% /
none 501936 0 501936 0% /dev
/tmp 506164 896 505268 1% /tmp
/run 506164 3852 502312 1% /run
/dev/shm 506164 4 506160 1% /dev/shm
none 4 0 4 0% /sys/fs/cgroup
cgmfs 100 0 100 0% /run/cgmanager/fs
/dev/vg1002/lv 2879475248 2872302088 7054376 100% /volume5
/dev/vg1003/lv 5809392448 5470867060 338406604 95% /volume6
/dev/vg1004/lv 5621463124 416 5621445712 1% /volume7
/dev/vg2/volume_4 2878443120 2874546768 3777568 100% /volume4
/dev/vg1/volume_3 955610564 835437344 120054436 88% /volume3
/dev/vg1001/lv 1918061032 1876703212 41239036 98% /volume2
/dev/vg1000/lv 1917962728 1273629824 644214120 67% /volume1
admin@DISKSTATION:~$ sudo btrfs subvolume list -a /dev/mapper/vg1004/lv
ERROR: cannot access '/dev/mapper/vg1004/lv': No such file or directory
ERROR: can't access '/dev/mapper/vg1004/lv'
admin@DISKSTATION:~$ sudo btrfs subvolume list -a /dev/vg1004/lv
ERROR: not a btrfs filesystem: /dev/vg1004/lv
ERROR: can't access '/dev/vg1004/lv'
admin@DISKSTATION:~$ sudo btrfs subvolume list -a /volume1
ERROR: not a btrfs filesystem: /volume1
ERROR: can't access '/volume1'
From the df
command, this seems like /dev/vg1004/lv
is the right device/filesystem.
It's odd however than the script only searches in volume1, I'll look into it this evening although it's hard for me to test as I don't have the same configuration etc.
Hello,
Sorry to bother you, is there any chance to test?
I will try to test it this evening. Maybe try with an empty export RECENT_FILEPATH=
Ok so first of all, setting my RECENT_FILEPATH=/volume1
does not work for me either, it's better if you write a filename or part of the path (i.e. mydir1/mydir2/myfile.txt
). (I only have one volume)
As you only have 10 raw roots found, you should really set RECENT_FILEPATH=
(to nothing) and the first root should be fine. You can always try with the 9 other roots as well.
On my Synology NAS (4x4TB drives) with BTRFS, I have 43830 roots found, so I cannot try them all.
And also the script works on my NAS, what's your Bash version? (use bash --version
)
admin@DISKSTATION:/volume1/scripts$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
the result of setting RECENT_FILEPATH= to nothing:
admin@DISKSTATION:/volume1/scripts$ sudo ./restore4.sh
RESTORE SCRIPT
Finding all roots...6 found
Searching for in the roots block numbers...
Trying roots block numbers: 29884416
Root block number 29884416 contains - recover from this root block number? (y/n) [y]: y
Recovering /dev/vg1004/lv to /volume1/restore1/files with root block number 29884416...
parent transid verify failed on 29884416 wanted 14881 found 14880
parent transid verify failed on 29884416 wanted 14881 found 14880
parent transid verify failed on 29884416 wanted 14881 found 14880
parent transid verify failed on 29884416 wanted 14881 found 14880
Ignoring transid failure
Restoring /volume1/restore1/files/@syno
Restoring /volume1/restore1/files/@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@eaDir/snaptree.bin
Done searching /@syno/@eaDir
Restoring /volume1/restore1/files/@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@iSCSI/tmp
Reached the end of the tree searching the directory
Done searching /@syno/@iSCSI
Restoring /volume1/restore1/files/@syno/@tmp
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20435.1570692964.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20435.1570692967.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20435.1570692968.rss
Restoring /volume1/restore1/files/@syno/@tmp/synodl_rss/20435.1570692969.rss
Done searching /@syno/@tmp/synodl_rss
Done searching /@syno/@tmp
Done searching /@syno
Reached the end of the tree searching the directory
Root block number 29884416 contains - recover from this root block number? (y/n) [y]: y
Try n
to try the next root block number
Recovering /dev/vg1004/lv to /volume1/restore1/files with root block number 29884416..
You should unmount the filesystem (so all the volumes) I think. And don't recover on the same device you are trying to recover from, use an external drive in USB for example.
hi quentin,
thanks for uploading this script. It helped me a lot. I have some notations for you, but i'm not a programmer so i'm not firm with the linux shell.
for subvolume add param: -r 223 for permission and attrib restore add: -x -m for regex add param: --path-regex "^/(|Folder(|/.*))$"
This save a lot of time and makes it more valueable. So my script line looks then as this: II use the para definition in the begining:
SUBVOLID=223 PATH_EX=Folder
btrfs restore -iv -x -m -t "$BLOCK" -r "$SUBVOLID" --path-regex "^/(|$PATH_EX(|/.*))$" "$DISK_TO_RECOVER" "$RESTORE_PATH" 2>&1 | tee btrfs-restore.log;
@qdm12 Thanks for providing this script. I'm stuck on a Failure 1 and I think it's due to providing the wrong DISK_TO_RECOVER location for my Synology NAS. I see in the examples above using a /dev/... path. On my Terminal is shows the NAS as //username@DeviceName.afpovertcp._tcp.local/Shared Folder Name
I'm wondering if I need to mount the NAS differently so I get a /dev/ or something else? Thanks!