blob: 19bff187013e8cd333beef97695da2fa3dc27ebf (
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
25
26
27
|
#!/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 )
COUNT=0
for PKG in ${PACKAGES}; do
FILES=$(ls -1t ${PKG}-*.properties 2>/dev/null | sed 1d)
FILES="${FILES:+${FILES} }$(ls -1t ${PKG}-*.tar.* 2>/dev/null | sed 1d)"
FILES="${FILES:+${FILES} }$(ls -1t ${PKG}-*.apk.* 2>/dev/null | sed 1d)"
test -n "${FILES}" && rm ${FILES}
COUNT=$((COUNT + $(echo ${FILES} | wc -w)))
done
test ${COUNT} -gt 0 && echo "Cleared ${COUNT} files from ${BACKUPPATH}"
|