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

On 23 December 2010 12:02, Nicolas Aizier <nicolas.aiz...@googlemail.com>wrote:

> Yeah actually I managed to write some script to help in doing that but
> it's a bit dirty.
> It would be good to have a cleaner and more precise wait to do it.
> In puppet dashboard for example it would be nice to have the list of
> files changed on a specific server with the corresponding date and MD5
> checksum.
> I'll propose that to developpement, seems a good idea. Because once
> you know the MD5 you're looking for your good with the actual system.
> We just miss a browsing/finding method.
>
> Thx for you help Felix !
>
> On Dec 22, 7:34 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de>
> wrote:
>  > On 12/22/2010 04:28 AM, Nicolas Aizier wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > Hi everyone,
> >
> > > I've got several questions that are most probably obvious to some of
> > > you but I'm actually a bit 'in the fog' about filebucket.
> >
> > > backup are done on a md5 basis so 1 file is generated whatever the
> > > number of clients if it's the same md5. That a really good option.
> > > On the other hand let's say that after 3 months I need to restore a /
> > > etc/ntp.conf file for a specific server. How the hell I know the old
> > > file md5 checksum ?
> > > I'm actually using puppet dashboard and I'll not open all the reports
> > > to find the md5 checksum, and as the file might have been taken from
> > > another server perhaps the checksum didn.t even appear in the server
> > > reports ....
> >
> > > Hope you see my point. From my actual point of view it's a great
> > > backup tool but restoring seems a bit tricky. But I'm sure someone
> > > will enlighten my soon since everything is really good in puppet so I
> > > guess problem come from me as usual ;-)
> >
> > Hi,
> >
> > those are very good points, actually. If you don't have the logs anymore
> > (and you probably don't), restoring is indeed tricky. Here's what I do
> > in that case:
> >
> > 1. grep through all /var/lib/puppet/bucket/.../paths files for the
> > filename in question
> > 2. sort the resulting subdirs by mtime
> > 3. find the closest one to my mark
> > 4. huzzah
> >
> > Maybe there are already some wrappers out there for this, but it's a
> > rare use case for me so I'm content as is.
> >
> > ...or maybe I've bein Doing It Wrong until now and someone else can tell
> > us now.
> >
> > Cheers,
> > Felix
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to