From owner-freebsd-stable@FreeBSD.ORG Fri Apr 15 09:23:57 2011 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 130C3106566C for ; Fri, 15 Apr 2011 09:23:57 +0000 (UTC) (envelope-from inyaoo@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8F7948FC18 for ; Fri, 15 Apr 2011 09:23:56 +0000 (UTC) Received: by bwz12 with SMTP id 12so2751685bwz.13 for ; Fri, 15 Apr 2011 02:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=nfo/R79W3w9tWdWoZwI40hjBfsJErBlS1uipXQGjEOs=; b=neIEu3xS1HU8kaJw+qMWALiVx5iS9EFHVzqpPn5kxUjo+j3w2ogiKLZiWUpFuk/ZPl J93EPeYuF8VCXlf3AjwH6NiOAE+qb4KpvC6Xov/EQujDn8yB3GPaHYLliA5ZOaLj8yrp q8OKc/GuKjfj1AhDehQc8IMGOJ6A/BofgcGBg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=kv6YvAsLwclyKwkC6xGxj2T9k2II/eQXW/SNga2qHXMwzPbEfVTPp9nGUqr1NfoI+D Cj8u0Vww1eW5fQM8q4+kC7gjfLWZDbtJVR2xD9V4LKNtjWHTjUbtSWU7WTAmD1+tTRTg Dc1iQFbBDcnfPGfxVRC0qghzTVOY4lsw8ir4Y= Received: by 10.204.143.4 with SMTP id s4mr1367301bku.98.1302857851063; Fri, 15 Apr 2011 01:57:31 -0700 (PDT) Received: from localhost (94-23-152-124.ovh.net [94.23.152.124]) by mx.google.com with ESMTPS id v21sm1413263bkt.23.2011.04.15.01.57.27 (version=SSLv3 cipher=OTHER); Fri, 15 Apr 2011 01:57:29 -0700 (PDT) From: Pan Tsu To: "J. Hellenthal" In-Reply-To: <201104140922.p3E9M246053052__4754.10261792621$1302775251$gmane$org@DataIX.net> (J. Hellenthal's message of "Thu, 14 Apr 2011 05:22:02 -0400 (EDT)") References: <201104140922.p3E9M246053052__4754.10261792621$1302775251$gmane$org@DataIX.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) Date: Fri, 15 Apr 2011 12:57:15 +0400 Message-ID: <86fwpjc2ok.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Cc: stable@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org Subject: Re: conf/156396: Make 220.backup-pkgdb cd(1) and backup only the package database. X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2011 09:23:57 -0000 "J. Hellenthal" writes: [...] > @@ -33,7 +33,8 @@ > > new_bak_file=`mktemp ${bak_file}-XXXXX` > > - if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then > + cd $pkg_dbdir/.. > + if tar -cjf "${new_bak_file}" "$(basename $pkg_dbdir)"; then Why not use `-s' (substitution) option of bsdtar(1)? if tar -cjf "${new_bak_file}" -s "|$pkg_dbdir||" "$pkg_dbdir"; then $(basename $pkg_dbdir) is technically wrong as PKG_DBDIR points not to /var/db but to /var/db/pkg by default and is not guaranteed to contain `pkg' at the tail, e.g. PKG_DBDIR is /foo, so /var/backups/pkgdb.bak.tbz-XXX has foo/ prefix PKG_DBDIR is /blah/bar, so /var/backups/pkgdb.bak.tbz-YYY has bar/ prefix It only adds one more hoop to jump through when restoring from backup, e.g. tar xf /var/backups/pkgdb.bak.tbz-XXX --strip-components 1 -C $PKG_DBDIR ...