conf/156396: Make 220.backup-pkgdb cd(1) and backup only the package database.

J. Hellenthal jhell at
Thu Apr 14 10:00:21 UTC 2011

>Number:         156396
>Category:       conf
>Synopsis:       Make 220.backup-pkgdb cd(1) and backup only the package database.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 14 10:00:01 UTC 2011
>Originator:     J. Hellenthal
>Release:        FreeBSD 8.2-STABLE i386
System: FreeBSD 8.2-STABLE #0 r220564M Tue Apr 12 10:02:17 EDT 2011 i386

Currently the backup script archives a full path starting from '/' and then strips the leading slash off of the path which is correct. Upon extraction that full path without the leading slash is extracted in the current directory as var/db/pkg/<contents> with the first two and possibly more directories left empty.

If a user has a different PKG_DBDIR as designated by ports(7) that is larger this can lead to frustration with the length of emptiness in the archive with the leading paths.
Run ( /etc/periodic/daily/220.backup-pkgdb ) and extract the archive located in /var/backups/
This patch makes 220.backup-pkgdb respectifully cd to where the pkgdb is located and create the archive from the relative path so there is only the pkgdb directory and contents upon extraction.

diff -r aa37d382121b -r 3fbae1ba29a4 etc/periodic/daily/220.backup-pkgdb
--- a/etc/periodic/daily/220.backup-pkgdb
+++ b/etc/periodic/daily/220.backup-pkgdb
@@ -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
 	    chmod 644 "${new_bak_file}"
 	    if [ -e "${bak_file}.2" -a -e "${bak_file}" ]; then



More information about the freebsd-bugs mailing list