Last active
April 9, 2026 20:44
-
-
Save dwburke/c6589fe8f79aaa0ad5cc3405a3a1bb57 to your computer and use it in GitHub Desktop.
batchprotect.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/bin/bash | |
| set -e | |
| OIFS="$IFS" | |
| IFS=$'\n' | |
| list=$(find . -type f | sort) | |
| #list=$(find . -type f | shuf) | |
| numleft=$(echo "$list" | wc -l) | |
| echo "$numleft original files left" | |
| for file in $list ; do | |
| if [[ $file == *"/.sync/"* ]]; then | |
| echo "$file is .sync skipping" | |
| continue | |
| fi | |
| ending=$(echo "$file" | sed 's/\(.*\)\.\(.*\)$/\2/') | |
| #include this block if you want to have 20% recovery data | |
| if [ ! -e "$file-20p.par2" ] && [ "$ending" != "par2" ] && [ "$ending" != "sig" ] && [ "$(stat --format=%s "$file")" != 0 ]; then | |
| echo "$numleft original files left" | |
| par2create -v -v -n1 -r20 "$file" | |
| rm "$file".par2 | |
| mv "$file".vol*par2 "$file"-20p.par2 | |
| fi | |
| #include this block if you want to have 100% recovery data | |
| #if [ ! -e "$file-100p.par2" ] && [ "$ending" != "par2" ] && [ "$ending" != "sig" ] && [ "$(stat --format=%s "$file")" != 0 ]; then | |
| #echo "$numleft original files left" | |
| #par2create -q -n1 -r100 "$file" | |
| #rm "$file".par2 | |
| #mv "$file".vol*par2 "$file"-100p.par2 | |
| #fi | |
| #include this block if you want to check for normal AND cryptographic integrity | |
| #if [ ! -e "$file.sig" ] && [ "$ending" != "par2" ] && [ "$ending" != "sig" ]; then | |
| #gpg --default-key C0FFEEBEEFC0FFEEBEEFC0FFEEDEADBEEF31415926 --detach-sign --yes "$file" | |
| #fi | |
| numleft=$((numleft-1)) | |
| done | |
| IFS="$OIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment