Make 220.backup-pkgdb cd(1) and backup only the package database.

J. Hellenthal jhell at DataIX.net
Thu Apr 14 09:52:02 UTC 2011


>Submitter-Id:	current-users
>Originator:	J. Hellenthal
>Organization:	
>Confidential:	no 
>Synopsis:	Make 220.backup-pkgdb cd(1) and backup only the package database.
>Severity:	non-critical
>Priority:	medium
>Category:	conf
>Class:		change-request
>Release:	FreeBSD 8.2-STABLE i386
>Environment:
System: FreeBSD 8.2-STABLE #0 r220564M Tue Apr 12 10:02:17 EDT 2011 i386

	
>Description:
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.
	
>How-To-Repeat:
Run ( /etc/periodic/daily/220.backup-pkgdb ) and extract the archive located in /var/backups/
	
>Fix:
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.

http://patches.jhell.googlecode.com/hg/220.backup-pkgdb_cd.patch?r=f60df831e62d64fd336b6c6612a6619eaf17a17f

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-stable mailing list