{"id":322,"date":"2009-09-02T16:58:43","date_gmt":"2009-09-02T21:58:43","guid":{"rendered":"http:\/\/it.thelibrarie.com\/weblog\/?p=322"},"modified":"2009-09-02T16:58:43","modified_gmt":"2009-09-02T21:58:43","slug":"7zip-batch-file-and-rotate-file-names","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2009\/09\/7zip-batch-file-and-rotate-file-names\/","title":{"rendered":"7zip Batch File and Rotate File Names"},"content":{"rendered":"<p>Here&#8217;s the scenario:<br \/>\nCustomer has a syslog server (Kiwi&#8217;s free syslog server) running on Windows2003 Server on a crappy 100GB server.  They wanted a way to rotate the logs (free version does not allow for automatic rotation) and compress the logs.  Every hour the syslog file grows by 7MB.  That might not seem like a lot, but each month that&#8217;s 5.2GB and every year it&#8217;s 61GB.  OK, maybe that&#8217;s not a lot to you, but on a 100GB server it adds up quickly.<\/p>\n<p>I compressed a test log of 46MB.  It compressed to 8KB.  Wow, eh?  7Zip is free, you can download it using sourceforge so it&#8217;ll run on Windows or linux.<\/p>\n<p>I wrote up a batch file to auto grab, compress, and name the file after the date.  You&#8217;ll need to add the 7z variable to the system path to make things easier (system variables, under path add C:\\program files\\7-zip)<\/p>\n<p><code>@echo off<\/code><br \/>\n<code>7z a c:\/%date:~4,2%-%date:~7,2%-%date:~10,4%-syslog.7z c:\/test\/<\/code><br \/>\n<code>pause<\/code><\/p>\n<p>As a breakdown, the first line turns off writing the commands on the executed script window.<br \/>\n7z is the executable, a is add files, the date spits out month-day-year followed by -syslog.7z, c:\/test\/ is the path you want compressed<br \/>\nPause just makes it so you have to hit enter to close the command window<\/p>\n<p>Obviously change the c:\/test\/ to something you want to backup.  You can also use c:\/test\/test.jpg as a specific file name.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the scenario: Customer has a syslog server (Kiwi&#8217;s free syslog server) running on Windows2003 Server on a crappy 100GB server. They wanted a way to rotate the logs (free version does not allow for automatic rotation) and compress the logs. Every hour the syslog file grows by 7MB. That might not seem like a &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2009\/09\/7zip-batch-file-and-rotate-file-names\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">7zip Batch File and Rotate File Names<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-microsoft"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":3,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":325,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/322\/revisions\/325"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}