[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#160743: efficient local package cache backup for autoclean/clean



We all know 

 # apt-get autoclean
clean local cached package files. (or apt-get clean)

But simply doing this is too aggressive to my taste.

(We lose older but recent packages which may be the ones needed for
recovering from recent broken upgrade process.)

Attached simple script run from cron job daily or weekly seems to ease
this issues.  (I just wrote it. So some tuning and debug are needed.)

If APT offers standard script along this kind of backup using hardlinks,
it may be interesting.

root@dambo:/var/cache/apt# du -sh * .
1.1G    archives
1.1G    backup-1              <-- daily back up :)
1.1G    backup-2              <-- ,,
1.1G    backup-3              <-- ,,
5.9M    pkgcache.bin
5.8M    srcpkgcache.bin
1.2G    .                     <--- look it is small !

Osamu

#! /bin/sh -e
# backup /var/cache/apt/archives/*.deb (3 levels)

# Written by Osamu Aoki <osamu@debian.org> for Debian (http://www.debian.org),
# PUBLIC DOMAIN.

PATH=/bin:/sbin:/usr/bin:/usr/sbin
if [ -x /usr/bin/aptitude ]; then 
  APTCMD=/usr/bin/aptitude
elif [ -x /usr/bin/apt-get ]
  APTCMD=/usr/bin/apt-get
else
  exit 0
fi

# move to /var/cache/apt
mkdir -p /var/cache/apt/archives
cd /var/cache/apt

# backup-3
rm -rf backup-3
mkdir -p backup-2
mv backup-2 backup-3
# backup-2
mkdir -p backup-1
mv backup-1 backup-2
# backup-1
mkdir -p backup-1
cd /var/cache/apt/archives
for i in *.deb; do
  ln -f $i ../backup-1/$i
done
cd /
$APTCMD update
$APTCMD autoclean

Reply to: