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)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2013-03-05 17:00 UTC by carlj
Modified: 2022-10-17 12:36 UTC (History)
0 users

See Also:


Attachments

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.

Fix: 

+       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 @@
            rc=3
        fi ;;
 esac
+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
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:36:36 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>