"J. Hellenthal" <[email protected]> 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 ...
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[email protected]"

Reply via email to