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,$md5sum,$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."
fi