5 # Backup the 7 last versions of dpkg databases containing user data.
6 if cd /var/backups ; then
7 # We backup all relevant database files if any has changed, so that
8 # the rotation number always contains an internally consistent set.
10 dbfiles="arch status diversions statoverride"
11 for db in $dbfiles ; do
12 if ! cmp -s dpkg.${db}.0 $dbdir/$db ; then
17 if [ "$dbchanged" = "yes" ] ; then
18 for db in $dbfiles ; do
19 [ -e $dbdir/$db ] || continue
20 cp -p $dbdir/$db dpkg.$db
21 savelog -c 7 dpkg.$db >/dev/null
25 # The alternatives database is independent from the dpkg database.
28 # Switch the alternatives database backups from xz to gzip, as the latter
29 # is Essential and we can rely on it being always present, using xz here
30 # is not worth the trouble, disk space savings, or possible additional
32 for dbseq in `seq 1 6` ; do
33 dbfile=${dbalt}.tar.${dbseq}
34 [ -e "${dbfile}.xz" ] || continue
39 # XXX: Ideally we'd use --warning=none instead of discarding stderr, but
40 # as of GNU tar 1.27.1, it does not seem to work reliably (see #749307).
41 if ! test -e ${dbalt}.tar.0 ||
42 ! tar -df ${dbalt}.tar.0 -C $dbdir $dbalt >/dev/null 2>&1 ;
44 tar -cf ${dbalt}.tar -C $dbdir $dbalt >/dev/null 2>&1
45 savelog -c 7 ${dbalt}.tar >/dev/null