dpkg.cron.daily 962 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. dbdir=/var/lib/dpkg
  3. # Backup the 7 last versions of dpkg databases containing user data.
  4. if cd /var/backups ; then
  5. # We backup all relevant database files if any has changed, so that
  6. # the rotation number always contains an internally consistent set.
  7. dbchanged=no
  8. dbfiles="arch status diversions statoverride"
  9. for db in $dbfiles ; do
  10. if ! cmp -s dpkg.${db}.0 $dbdir/$db ; then
  11. dbchanged=yes
  12. break;
  13. fi
  14. done
  15. if [ "$dbchanged" = "yes" ] ; then
  16. for db in $dbfiles ; do
  17. cp -p $dbdir/$db dpkg.$db
  18. savelog -c 7 dpkg.$db >/dev/null
  19. done
  20. fi
  21. # The alternatives database is independent from the dpkg database.
  22. if ! test -e alternatives.tar.0 ||
  23. ! tar -df alternatives.tar.0 -C $dbdir alternatives >/dev/null ; then
  24. tar -cf alternatives.tar -C $dbdir alternatives
  25. savelog -c 7 -J alternatives.tar >/dev/null
  26. fi
  27. fi