From owner-freebsd-ports@FreeBSD.ORG Wed May 13 11:06:48 2015 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3278E86C for ; Wed, 13 May 2015 11:06:48 +0000 (UTC) Received: from homiemail-a46.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) by mx1.freebsd.org (Postfix) with ESMTP id 0D4EB1613 for ; Wed, 13 May 2015 11:06:47 +0000 (UTC) Received: from homiemail-a46.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a46.g.dreamhost.com (Postfix) with ESMTP id 9B4ED3E405B; Wed, 13 May 2015 04:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=ozzmosis.com; h=date:from :to:cc:subject:message-id:references:mime-version:content-type: in-reply-to; s=ozzmosis.com; bh=ymIoBx7taiFPzuucCKemy/kylzk=; b= mqOCWucqXDGndV3YgnT95/xE9tdmwWyyxtTClFBW5DDvMCuaTI4+2UHMOHwNux80 mHioFFWgfx1uSc7fR6rKfPROcK5EF+vhiRXkPH4vs3DvZX3z7wdhnluJGLIrJzsG IMh/s6jeEr8z7EeveKjV+6RZgv9syEVhbWkzfD1YgVo= Received: from blizzard.ozzmosis.com (124-170-17-20.dyn.iinet.net.au [124.170.17.20]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: relay@ozzmosis.com) by homiemail-a46.g.dreamhost.com (Postfix) with ESMTPSA id 5EAA23E4057; Wed, 13 May 2015 04:06:46 -0700 (PDT) Received: by blizzard.ozzmosis.com (Postfix, from userid 1001) id 623FE5CFE; Wed, 13 May 2015 21:06:44 +1000 (AEST) Date: Wed, 13 May 2015 21:06:44 +1000 From: andrew clarke To: Peter Jeremy Cc: Scott Bennett , freebsd-ports@freebsd.org Subject: Re: damage to pkg's sqlite data base Message-ID: <20150513110644.GA20802@ozzmosis.com> References: <201505120617.t4C6HkA3019096@sdf.org> <0dcbdcb9fdfdebc53a2563b11494f61b@ultimatedns.net> <201505130512.t4D5Cpqa011080@sdf.org> <20150513081244.GB18834@ozzmosis.com> <20150513090027.GB25775@server.rulingia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150513090027.GB25775@server.rulingia.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2015 11:06:48 -0000 On Wed 2015-05-13 19:00:27 UTC+1000, Peter Jeremy (peter@rulingia.com) wrote: > On 2015-May-13 18:12:44 +1000, andrew clarke wrote: > >You can reinstall just those ports. Check /var/log/messages, eg. > > > >$ grep pkg /var/log/messages > >May 12 14:34:38 blizzard pkg: poudriere upgraded: 3.1.4 -> 3.1.6 > >May 12 14:38:08 blizzard pkg: git-lite-2.4.0 installed > >May 13 08:29:04 blizzard pkg: sqlite3 upgraded: 3.8.9_1 -> 3.8.10.1 > >May 13 08:29:05 blizzard pkg: spamassassin reinstalled: 3.4.1_1 -> 3.4.1_1 > >May 13 08:29:05 blizzard pkg: ca_root_nss upgraded: 3.18.1 -> 3.19 > > That assumes you have syslog messages back to when you started using pkg. > syslog was never intended to provide an audit trail. True. I'd been wondering about why the pkg developers didn't add logging functionality, but it looks like I just needed to add this to /etc/syslog.conf: !pkg *.* /var/log/pkg.log then run: sudo touch /var/log/pkg.log sudo service restart syslogd I think that's correct. I'm not sure the syslog.conf entry above will include pkg-static - maybe it should be "!pkg*" instead? I must admit I find the syslog.conf man page to be not very helpful. $ cat /var/log/pkg.log May 13 20:58:25 blizzard pkg: jive-1.1 deinstalled May 13 20:58:29 blizzard pkg: jive-1.1 installed I tend to think pkg.log creation & use should be a normal thing for a new FreeBSD install. > >The "trick" is to revert to a known-good backup of the pkg database > >that's generated daily by /usr/local/etc/periodic/daily/411.pkg-backup > >in /var/backups/ : > > > >-rw-r--r-- 1 root wheel 2207320 2015-05-13 04:20:30 pkg.sql.xz > >-rw-r--r-- 1 root wheel 2196088 2015-05-12 04:21:24 pkg.sql.xz.2 > > Assuming that they aren't corrupt. But that's better than nothing. Note > that the backup is taken every day, whether or not there has been any > change to the pkg database, so you have 2 days of backups, not the last > two revisions. Yes, that's a deficiency in the periodic script. Probably not difficult to improve either, with the correct use of /usr/bin/diff. > On 2015-May-13 18:17:12 +1000, andrew clarke wrote: > >Actually I was wrong about this. The pkg command has the sqlite3 > >interpreter built-in, accessed via "pkg shell", that opens local.sqlite > >by default: > > Some experimenting suggests that none of the pragma commands work in > "pkg shell", so you probably will need to find a copy of sqlite3. Oh dear, that's unfortunate. Regards Andrew