Date: Fri, 15 Apr 2011 12:57:15 +0400 From: Pan Tsu <inyaoo@gmail.com> To: "J. Hellenthal" <jhell@DataIX.net> 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. Message-ID: <86fwpjc2ok.fsf@gmail.com> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
"J. Hellenthal" <jhell@DataIX.net> 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 ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86fwpjc2ok.fsf>