<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -14,6 +14,7 @@ class BackupFu
     @fu_conf = fu_conf[RAILS_ENV].symbolize_keys
     @fu_conf[:mysqldump_options] ||= '--complete-insert --skip-extended-insert'
     @verbose = !@fu_conf[:verbose].nil?
+    @fu_conf[:keep_backups] ||= 5
     check_conf
     create_dirs
   end
@@ -114,6 +115,24 @@ class BackupFu
     
   end
   
+  def cleanup
+    count = @fu_conf[:keep_backups].to_i
+    backups = Dir.glob(&quot;#{dump_base_path}/*.{sql}&quot;)
+    if count &gt;= backups.length
+      puts &quot;no old backups to cleanup&quot;
+    else
+      puts &quot;keeping #{count} of #{backups.length} backups&quot;
+      
+      files_to_remove = backups - backups.last(count)
+      files_to_remove = files_to_remove.concat(Dir.glob(&quot;#{dump_base_path}/*.{gz}&quot;)[0, files_to_remove.length]) unless @fu_conf[:disable_tar_gzip]
+      
+      files_to_remove.each do |f|
+        File.delete(f)
+      end
+      
+    end
+  end
+  
   private
   
   def establish_s3_connection</diff>
      <filename>lib/backup_fu.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,6 +43,12 @@ namespace :backup_fu do
     b.backup_static
   end
   
+  desc &quot;Clean up old backups. By default 5 backups are kept (you can change this with with keep_backups key in config/backup_fu.yml).&quot;
+  task :cleanup do
+    b = BackupFu.new
+    b.cleanup
+  end
+  
   namespace :static do
 
     desc &quot;Tars and gzips static application files locally.  Does *not* upload to S3.&quot;</diff>
      <filename>tasks/backup_fu_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d51fa7aa9779f3524c43800f3b500128402c8421</id>
    </parent>
  </parents>
  <author>
    <name>Michael Breen</name>
    <email>mikebreen@bigroomtechnology.com</email>
  </author>
  <url>http://github.com/ashchan/backup_fu/commit/209b223474386da994916f79182cedb4d4d2f698</url>
  <id>209b223474386da994916f79182cedb4d4d2f698</id>
  <committed-date>2008-06-25T09:35:33-07:00</committed-date>
  <authored-date>2008-06-25T09:35:33-07:00</authored-date>
  <message>added cleanup task to remove local backups</message>
  <tree>07bc7f2625da8d37cf8f4af82d043bf366323d46</tree>
  <committer>
    <name>Michael Breen</name>
    <email>mikebreen@bigroomtechnology.com</email>
  </committer>
</commit>
