Yes, I seem to recall that was a bit of a hassle. I think you have to be careful from where you execute the command. My script does the following (I don’t know which bits are critical, and which are just how I wrote it)…
Assuming you want to make a parchive of the file:
/backup/restic_repo/data/c4/c4048768c4bd77232a7ffc5c4c3671b13e0234c246c80ceabbcd1a68365d1c58
into the file:
/backup/restic_par/restic_repo/data/c4/c4048768c4bd77232a7ffc5c4c3671b13e0234c246c80ceabbcd1a68365d1c58-5.par2
Then run the following commands:
cd /backup
par2create -B ./ -p -n1 -r5 /backup/restic-par/restic-repo/data/c4/c4048768c4bd77232a7ffc5c4c3671b13e0234c246c80ceabbcd1a68365d1c58 restic-repo/data/c4/c4048768c4bd77232a7ffc5c4c3671b13e0234c246c80ceabbcd1a68365d1c58
My full script is below. Use at your own risk :)
#!/bin/bash
#paths to the repo and the parchive directory
rootpath=/path/below/repo
repodir=restic_repo
pardir=restic_repo_parchive
#percentage redundancy desired
PERC=5
#oldest file for which to create parchive files (-3 = 3 days before present)
mtime=-3
cd $rootpath
#find any files changed within $mtime days and pipe them into the do loop
find $repodir -type f -mtime $mtime -print0 | while IFS= read -r -d '' FILE
do
DIR=$(dirname "${FILE}")
DIR_OUT="$rootpath/$pardir/${DIR}"
FILENAME=$(basename "${FILE}")
PAR_ROOT_OUT="$DIR_OUT/${FILENAME}"
FILE_OUT="$DIR_OUT/${FILENAME}"-$PERC.par2
#create directory if it doesn't exist
if [[ ! -d $DIR_OUT ]]; then
echo making directory "$DIR_OUT"
mkdir -p "$DIR_OUT"
fi
#create par file if it doesn't exist
if [ ! -f "$FILE_OUT" ]; then
echo executing: par2create -B ./ -p -n1 -r$PERC "${PAR_ROOT_OUT}" "${FILE}"
echo in `pwd`
par2create -B ./ -q -n1 -r$PERC "${PAR_ROOT_OUT}" "${FILE}"
#remove the unnecessary file created by par2create
rm "${PAR_ROOT_OUT}".par2
#and rename the other file to the correct name
mv "${PAR_ROOT_OUT}".vol*par2 "$FILE_OUT"
fi
done