Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Our current backup approach requires us to capture a Tomcat directory, and all it's contents. The rationale is the backup makes redeployment easier in the event of a disaster.

It was rotating based on the day number, so we'd have a rolling week of backups. Problem is that these are eating too much diskspace, and we really don't need that much history.

I looked at logrotate, but it seems to be set for specific log files. Is there some way of making logrotate capture a directory & contents, providing three rolling days history? Or is there a better alternative?

share|improve this question
    
+1 for being the SQL guru :) Glad to see you on SU! – JNK Sep 21 '10 at 18:55
    
sorry about the typo in my command, fixed. – Rich Homolka Sep 21 '10 at 21:25
up vote 1 down vote accepted

I've had similar requirements. My solution was backup a daily backup to a dir, then prune based on date.

find /path/to/backups/ -name 'tomcat*.tar.bz2' -atime +3 -mtime +3 -exec rm {} \;
DATE=$(date '+%Y-%m-%d')
tar -C /path/to/tomcat/root -cjvf /path/to/backups/tomcat-${DATE}.tar.bz2 .

Obviously, put this in cron. Run once daily.

share|improve this answer
    
+1: I'm getting a "tar: Cowardly refusing to create an empty archive" – OMG Ponies Sep 21 '10 at 20:06
    
@OMG: you must specify the files you want to backup at the end of the tar command line.. – lorenzog Sep 21 '10 at 20:26
    
@lorenzog: I want the contents of the entire directory. – OMG Ponies Sep 21 '10 at 20:40
    
@OMG then just put . (the current directory) or the name of the directory if you're one level up. – lorenzog Sep 22 '10 at 7:13

What about using the -u option of tar (updates only newer files), and compressing the file every week?

Also think about this: is really disk space such a big issue? Given how little hard drives cost lately, is an hour of your time worth doing this compared to the cost of buying a TB of space and forgetting about it?

share|improve this answer
    
It's a co-located server, this is a VM. I can't throw in the drive, has to go through channels. The reality is that after a day, the data is out of sync with the database anyway. – OMG Ponies Sep 21 '10 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .