Tuesday, May 22, 2012

7zip to compress my backup files

I ran out of disk space on my db server last week. The obvious thing to do is to be a better stuard of the space allocated on the drive.

7zip is open source under the GNU license, like Wamp, like moodle. It is the obvious choice.

I downloaded 7zip and installed it on my server. Naturally, I did not read any directions. I simply launched the program and within a couple minutes had created two compressed files from backup.sql files. The first file I compressed went from 115 MB to 1.6 MB, using the default 7z format. The next file I compressed went from 60 MB to 6.2 MB, using the .zip format. That is pretty impressive. I will compress the overnight backup file into a .zip format and attempt to restore tomorrow am. databases compress well.

After another 15 minutes of experimentation, I have the entire directory zipped up and the non zipped files removed.  Wow, this is so obvious in hindsight.

This is my backup directory structure on the db server

backups
   \entity1
      monday backup.sql
      tuesday backup.sql
      wednesday backup.sql
      thursday backup.sql
      friday backup.sql
   \entity2
      .
      .
   \entity3
   .
   .
   \entity 12


This is my revised structure

backups
   \entity1
       weekbla.zip   
  \entity2
       weekbla.zip   
  \entity3
       weekbla.zip   
  \entity 12

Where weekbla.zip is a compressed file that contains all of the mon - fri .sql files. I can easily extract a single file from the zip archive if necessary.

You don't have to delete the older backup files, just compress them, dummy.

Brilliant and efficient, wonder if I can automate the compression process?

I just reduced the storage capacity of my backups folder from about 4.5GB to 500 MB.  

That should really help me to keep more backups around (which is what I want on this drive, not scattered all over) without endangering the entire system by running out of drive space.

Unless I can automate, I will spend about 10 - 15 minutes at the end of each week creating a new .zip file from the 5 backups that were created during the week.

No comments:

Post a Comment