Here's a script we use for this purpose:
#!/bin/bash
#
# Adapted from
http://markmail.org/message/nybqh3be7bcge33h#
if [ -z $1 ]
then
echo "This script is used to retrieve backups of files that were"
echo "updated by puppet but which you might want to retrieve or"
echo "reinstate. Remember that unless you add the retrieved file"
echo "back into puppet itself, it is likely to be overwritten again."
echo " "
echo "Usage: `basename $0` file_to_look_for"
echo "Example: `basename $0` /etc/monit.conf"
fi
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: "
echo "filebucket -b /var/lib/puppet/clientbucket get <md5sum>"
echo " "
echo "* To restore the file, issue this command: "
echo "filebucket restore -b /var/lib/puppet/clientbucket /path/to/new/file <md5sum>"
else
echo "No entries were found. Exiting."
fi
Sample output:
/usr/local/sbin/retrieve_from_puppet_bucket.sh /etc/monit.conf
Searching for local backups of file /etc/monit.conf (this may take some time)...
/etc/monit.conf de632936472996370c0d70b4179f720a 2010-12-23 13:49:55.000000000 +1100
/etc/monit.conf 4e0dd5f48f94b83c41175c2ff7c96746 2010-08-02 23:38:08.000000000 +1000
/etc/monit.conf d2fe867d318e76c1b438e5d7df0a1d5e 2009-08-17 10:07:46.000000000 +1000
/etc/monit.conf 5c78246620a54d1336d0e69743246bb8 2009-07-09 16:26:10.000000000 +1000
/etc/monit.conf b9a969263108fbc9a8d098cae95a8471 2009-06-16 14:47:11.000000000 +1000
/etc/monit.conf 34b069df755a6efa74c4559d86421fe9 2009-06-15 15:31:43.000000000 +1000
/etc/monit.conf 8f11b011577dd425914a905dc848669f 2009-06-15 09:27:20.000000000 +1000
/etc/monit.conf 6c51a25c755f0a46edc4cf960742eaf2 2009-06-15 08:57:12.000000000 +1000
/etc/monit.conf 76a7e9a9126550f0b9bc267c5d85c274 2009-06-10 11:39:58.000000000 +1000
/etc/monit.conf 706f438b2e1237d8cacfea3ea0f7b605 2009-06-10 11:09:28.000000000 +1000
/etc/monit.conf a39399f31a908865f7805af20349ba61 2009-06-09 10:17:49.000000000 +1000
/etc/monit.conf b1c038fddd7b16786be8b9a430bea446 2009-05-27 08:34:37.000000000 +1000
/etc/monit.conf 8dddca0780ac5b7c4a2c00fccba1a8b2 2009-04-15 17:28:49.000000000 +1000
/etc/monit.conf ca5749c937a825223e409640d8579a0a 2009-01-12 19:16:16.000000000 +1100
/etc/monit.conf fea1cedfb598d239672e772524bba2e7 2009-01-12 18:46:04.000000000 +1100
Horray, backup(s) were found!
* To view the contents of the file, issue this command:
filebucket -b /var/lib/puppet/clientbucket get <md5sum>
* To restore the file, issue this command:
filebucket restore -b /var/lib/puppet/clientbucket /path/to/new/file <md5sum>
I think this would suit your original request.
Cheers,
Iain