How to tame Jive's backup happy nature

I've been looking after a Jive box at work, and the other day, the site it provided went down round about the same we were moving offices (do sites ever go down at convenient times?). After checking the logs, it turned out that the culprit was Jive's sometimes handy, but greedy habit of creating a full dump of all the data, files added to a site every day, for the last 30 days.

When you're working with large uploads of Photoshop mockups this quickly burns through drive space, so I had to add a cronjob here to sweep away the older backups. There's a thread on Jive' forum's asking the same issue, so I thought I'd document it here:

First, open up your crontab as a user with the correct privileges:

  crontab -e

then add a line like this:

  # find all db dumps older than 7 days, and delete them
  # at minute 02, on hour 04, every day, every month, every year
  02 04 * * * find /usr/local/jive/var/data/backup/postgres/full -mtime +7 -exec rm -f {} \;

I've annotated the cron syntax cronwtf to help make it more readable, but the second snippet requires some explanation. This line here:

  find /usr/local/jive/var/data/backup/postgres/full -mtime +7 -exec rm -f {} \;  

Roughly translates as:

run a 'find' all files older than 7 days, and execute a command to delete (rm -f) each file in the collection

This creates our 'sweeper' script that clears away database dump files that would otherwise bring down the machine, leading you to lose face, and ultimately your place in society.

Note -mtime refers to the last modified time of a file. You can also think of this as the creation time of the file, as Unix does not distinguish between creation and modification. There's more here in the manpages

Copyright © 2020 Chris Adams
Powered by Cryogen
Theme by KingMob