regenerating /var/db/pkg

Doug Barton dougb at FreeBSD.org
Thu Apr 22 16:54:07 UTC 2010


On 4/22/2010 9:08 AM, Eitan Adler wrote:
> taking into account your feedback here is the new version
> If all is good I'll submit a PR....
> 
> #!/bin/sh
> #
> # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1
> 2009/10/25 01:10:29 kensmith Exp $
> #
> 
> # If there is a global system configuration file, suck it in.
> #
> if [ -r /etc/defaults/periodic.conf ]
> then
>     . /etc/defaults/periodic.conf
>     source_periodic_confs
> fi
> 
> bak=/var/backups
> db_loc="/var/db/pkg";

The trailing ; here is superfluous. Also, a better invocation might be:
db_loc=`pm_make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null`
to support people who redefine it.

> bk_loc="$bak/pkgdb.bak.tar"

Since you (properly) compress the archive on the tar command line, that
should be: bk_loc="$bak/pkgdb.bak.tar.bz2"

> case "$daily_backup_pkgdb_enable" in
>     [Yy][Ee][Ss])
> 	if [ ! -d $db_loc ]
> 	then
> 	    echo '$daily_backup_pkgdb_enable is enabled but' \
> 		"$db_loc doesn't exist"
> 	    rc=2
> 	else
> 	    rc=0
> 
> 	    echo ""
> 	    echo "Backing up package db directory:"
> 
> 	    rm -f $bk_loc

[ -e "$bk_loc" ] && unlink $bk_loc

> 	    tar -cjf $bk_loc $db_loc || rc=3
> 	fi;;
> 
>     *)  rc=0;;
> esac
> 
> exit $rc


hth,

Doug

-- 

	... and that's just a little bit of history repeating.
			-- Propellerheads

	Improve the effectiveness of your Internet presence with
	a domain name makeover!    http://SupersetSolutions.com/



More information about the freebsd-hackers mailing list