Jan 112012
 

A very basic .bat that archives a bunch of files using 7zip in a different package each day of the week (i.e. bak_1.7zip to bak_7.7zip), then copies the archive to a different machine in a shared folder and fires off an email with the result. Effectively a week’s worth of full backups. This is NOT real backup.

It needs 7zip, the command line version for creating the archive and Blat to send the email. By the way, Blat is really great, free of charge and the libraries are easy to use, you can integrate it in almost any programming language to send/receive email straight from your program. Awesome.
While you’re downloading additional programs for this, might as well get Realdate too and use it instead of line 5. The problem with parsing current date/time in .bat files is that DATE and TIME return their results in the system’s locale format, so on one computer it might be “2012-01-11”, while on another system it could be “Wed 01/11/2011” or somesuch. Line 5, as it is in this script, uses Windows Management Instrumentation to get the day of week, independent of locale settings. But, as Microsoft standards go, it doesn’t work on all versions of Windows. So instead of using some convoluted way of getting such simple information, if the line below doesn’t work just use Realdate.

Obviously, if PowerShell is available or some real scripting/programming language this can be much more elegant.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)