Bug 176668 - [periodic] [patch] Only save pkgdb if it has changed
Summary: [periodic] [patch] Only save pkgdb if it has changed
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2013-03-05 17:00 UTC by carlj
Modified: 2018-01-03 05:16 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description carlj 2013-03-05 17:00:02 UTC
The periodic daily scripts normally save the entire state of the pkgdb
and a backup, even when there are no changes.  That is a considerable
use of backup space when there is no change.  The accompanying patch to
/etc/periodic/daily/220.backup-pkgdb saves only if there have been some
changes in the /var/db/pkg/ directory.  I have tested the same patch on
8.3-RELEASE and 9.0-RELEASE systems.


+       changes=$(find $pkg_dbdir -newer $bak_file -print 2>&1 | wc -l)
+       if [ "$changes" -eq "0" ] ; then
+           echo 'No changes.'
+           exit 0
+       fi
        new_bak_file=`mktemp ${bak_file}-XXXXX`

        if tar -cjHf "${new_bak_file}" "$pkg_dbdir" 2>/dev/null; then
@@ -47,5 +53,6 @@
        fi ;;
+echo 'Done.'

 exit $rc--a8f6VQeGLHYdNABm8ipJbUtsgm2PtkrLkpvdZ2WsAoTDjvFF
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- /etc/periodic/daily/220.backup-pkgdb.orig   2013-03-01 10:45:28.199970000 -0800
+++ /etc/periodic/daily/220.backup-pkgdb        2013-02-27 15:32:45.201213000 -0800
@@ -32,6 +32,12 @@
        echo ''
        echo 'Backing up package db directory:'
How-To-Repeat: The normal behaviour is to always save.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:19 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped