Hi.
..and made some adjustsments. I've pasted the script below in case anyone else are in need of such a script:
--- snip ---
#!/bin/bash
file=$1
BUCKETDIR=$( puppetd --configprint clientbucketdir )
PREFIX="* "
entries_found=0
echo "Searching for local backups of file $file (this may take some time)..."
for f in $( find $BUCKETDIR -type f -name paths -exec grep -l $file {} \; |xargs -r ls -t);
do
md5sum=$( basename $(dirname $f))
filename=$(< $f )
modify_time=$(stat --format '%y' $f)
echo -e "$filename\t$md5sum\t$modify_time"
entries_found=1
done
if [ $entries_found -eq 1 ]; then
echo ""
echo "Horray, backup(s) were found!"
echo "* To view the contents of the file, issue this command: \"filebucket -b /var/lib/puppet/clientbucket get <md5sum>\""
echo "* To restore the file, issue this command: \"filebucket restore -b /var/lib/puppet/clientbucket /path/to/new/file <md5sum>\""
else
echo "No entries were found. Exiting."
--- snip ---
Note that the script retrieves files only from the local backup directory. I added the "-r" argument to xargs so that the loop structure would not run unless the "find" command actually find a match. Without the "-r" switch, the loop would run even if you pasted a invalid file name, which for me caused unexpected results.
Regards,
Kenneth