-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixscrewup
37 lines (30 loc) · 1.06 KB
/
fixscrewup
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
#!/bin/bash
#I screwed up a script and accidently deleted a bunch of files from a mergerfs share
#since the delete spanned drives a bunch of files were unrecoverable
#this script will pull in files from a cold storage mount and restore the files
#snapraid has labeled as unrecoverable. Running a snsapraid fix after this will
#also allow you to recover even more files through snapraid since the ones
#this recovers will no longer be missing.
#you could rsync the entire drive but then that would also restore files you deleted
#this will only restore files that are actually missing
declare -a arr
IFS='
'
snaploc="pool"
mountloc="/backups"
drivename="storage1"
coldname="cold$drivename"
arr=( $(find /sharedfolders/pool/ -name "*.unrecoverable"))
for i in "${arr[@]}"
do
tmp=${i#"$snaploc"}
tmp=${tmp%".unrecoverable"}
a=$(echo "$tmp" | sed 's/ /\\ /g')
#echo "$tmp"
if [[ -e "$mountloc$coldname/$snaploc/$tmp" ]]
then
rsync -ait --progress "$mountloc$coldname/pool/$tmp" "/srv/dev-disk-by-label-$drivename/$snaploc/$tmp"
else
echo "NOT FOUND: $tmp"
fi
done