Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
blob: cf41db643b8d06fd42ee822f74e5831aa2468468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# A quick script to delete all but the most recent backup for each app
# from Titanium Backup
#
# usage:
#
#     sudo crontab -e -u www
#
#         #minute hour    mday    month   wday    command
#         46      4       *       *       *       /operator/scripts/openbsd/titanium-cleanup.sh /srv/www/sites/narf.ssji.net/cloud/data/shtrom/files/Backups/snibbley/TitaniumBackup
#         16      4       *       *       *       /operator/scripts/openbsd/titanium-cleanup.sh /srv/www/sites/narf.ssji.net/cloud/data/jenny/files/Backups/BeanChicken

BACKUPPATH=${1}

cd ${BACKUPPATH}

PACKAGES=$(ls *.apk.*| sed s/-.*// | sort -u )

for PKG in ${PACKAGES}; do
	FILES=$(ls -1tr ${PKG}-*.properties		2>/dev/null | sed 1d)
	FILES="${FILES:+${FILES} }$(ls -1tr ${PKG}-*.tar.bz2	2>/dev/null | sed 1d)"
	FILES="${FILES:+${FILES} }$(ls -1tr ${PKG}-*.apk.*	2>/dev/null | sed 1d)"
	test -n "${FILES}" && rm ${FILES}
done