Cleanup options added to MAUCacheAdmin

Microsoft AutoUpdate 4For years I have been manually cleaning up old packages on my Microsoft AutoUpdate caching server. Since I was having to manually move around collateral files for the Manifest Server component each month it wasn’t much extra work.

However now that I have switched from a custom Manifest Server to Microsoft’s official curated deferral channels, I wanted to configure my caching server to be completely hands-off.

Spurred on by a request on GitHub I decided to finally write some code to automate the cleanup process. The changes were merged into MAUCacheAdmin back on November 30. Read on for the details.

By default automatic cleanup is disabled. To enable the feature change line 18 to “true” and set the number of days you would like to retain packages. Make sure to account for any deferrals you have in place.

For example if you are deferring updates for 14 days you will need to keep packages for at least 45 days to make sure they aren’t purged before clients start looking for the next version.

# Configure automatic cleanup of old data. Make sure to account for older versions you may want to continue hosting.
CLEANUP=false
CLEANUP_DAYS=90

A number of old application versions are always kept in cache to support older versions of macOS. The cleanup script starts by touching these files to update the modification date so they are not purged. This avoids unnecessary re-downloading.

Next it uses the find command to search for cache files older than configured and then deletes them.

CleanupOldFiles () {
# Cleanup old cache and manifest files
	if [ $CLEANUP = true ]; then
		echo "Touching legacy packages needed for older macOS versions to avoid re-download..."
		touch "$CACHEPATH/Microsoft_AutoUpdate_4.40.21101001_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Excel_16.30.19101301_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Excel_16.43.20110804_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Excel_16.54.21101001_Updater.pkg"		
		touch "$CACHEPATH/Microsoft_OneNote_16.30.19101301_Updater.pkg"
		touch "$CACHEPATH/Microsoft_OneNote_16.43.20110804_Updater.pkg"
		touch "$CACHEPATH/Microsoft_OneNote_16.54.21101001_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Outlook_16.30.19101301_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Outlook_16.43.20110804_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Outlook_16.54.21101001_Updater.pkg"
		touch "$CACHEPATH/Microsoft_PowerPoint_16.30.19101301_Updater.pkg"
		touch "$CACHEPATH/Microsoft_PowerPoint_16.43.20110804_Updater.pkg"
		touch "$CACHEPATH/Microsoft_PowerPoint_16.54.21101001_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Remote_Desktop_10.1.8_updater.pkg"
		touch "$CACHEPATH/Microsoft_Remote_Desktop_10.2.13_updater.pkg"
		touch "$CACHEPATH/Microsoft_Remote_Desktop_10.3.12_updater.pkg"
		touch "$CACHEPATH/Microsoft_Remote_Desktop_10.5.2_updater.pkg"
		touch "$CACHEPATH/Microsoft_Word_16.30.19101301_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Word_16.43.20110804_Updater.pkg"
		touch "$CACHEPATH/Microsoft_Word_16.54.21101001_Updater.pkg"
		echo "Removing old files..."
		find "$CACHEPATH" -type f -mtime +"$CLEANUP_DAYS" -print -delete
	fi
}

We run a seven day deferral and I have my cleanup configured at 60 days. Grab the latest version of MAUCacheAdmin if you’d like to take advantage of this new feature.

If you have any questions join us in the #microsoft-autoupdate channel of the MacAdmins Slack.

3 comments on “Cleanup options added to MAUCacheAdmin

  1. meta

    I like this feature (CLEANUP). Please, consider adding a commandline option for it, so one does not need to edit the script each time it is updated.

    Reply
  2. Pingback: Weekly News Summary for Admins — 2022-01-28 – Scripting OS X

Leave a Reply

Your email address will not be published.