On 09/25/2011 11:28 PM, g wrote: > On 09/25/2011 08:15 PM, sean darcy wrote: >> Doing something really silly, which erased /var/lib/rpm/. Sigh. >> >> Found http://www.sharp-tools.net/archives/000765.html which talks about >> recovering from an erasure by using a log file /var/lib/rpmpkgs that a >> cron job did on his system. Can't find any such file on my system. >> >> Any suggestions really appreciated. > > 1] use either; > > man rpm > or > info rpm > > search for word; > > --initdb This is of no use whatsoever in this situation, it doesn't help reconstructing the accidentally erased rpmdb contents. > 2] learn how to back up your system. While good advise, this doesn't help after the fact either. The best option is to see if the db can be undeleted as-is: avoid writing on the filesystem where /var/lib/rpm/ was and give extundelete (or other similar tool) a go: see http://extundelete.sourceforge.net/ for general undelete instructions. Extundelete is packaged in Fedora but you can't use rpm/yum to install it, you'll need to download it to some other partition than /var and unpack with rpm2cpio (and hope you had its dependencies installed) and use it from that temporary location. The all-important file is /var/lib/rpm/Packages, everything else is just indexes that can be recreated from the Packages file. IF you can find that with undelete-tricks then there should be zero loss of data: put the undeleted Packages file back to /var/lib/rpm/, run 'rpmdb --rebuilddb' and that's it. If undelete is not possible (eg /var has been written to which may have caused the deleted contents to be actually destroyed), things harder and more error prone. Your best chance might be /var/lib/yum/rpmdb-indexes/pkgtups-checksums, the script below will pull out a package list similar to what /var/log/rpmpkgs used to be: -- cut here -- #!/usr/bin/python f = open('/var/lib/yum/rpmdb-indexes/pkgtups-checksums') for x in [1, 2]: f.readline() lines = [] for l in f.readlines(): lines.append(l.strip()) pd = zip(*[lines[i::7] for i in range(7)]) for (n,a,e,v,r,x,y) in pd: print '%s-%s-%s.%s' % (n,v,r,a) -- cut here -- With that data, you can then try to reconstruct the rpmdb contents similarly to described in eg http://www.sharp-tools.net/archives/000765.html. Whether this is worth the trouble depends - reinstall might well be an easier option in practise. - Panu - -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines