Sensible Open Source

Blog Status

  • 6 yrs 43 wks 6 days old
  • Updated: 3 Feb 2012
  • 466 entries
  • 193 comments
Total: 2,261,842
since: 5 Apr 2005

LinkBlogS

Creating Vidcasts

18 June 2007, Monday 7:05 P GMT-06
Tags:      

Man, Can't Microsoft Catch A Break?

16 March 2007, Friday 12:26 P GMT-06

Viacom, Google andYou Tube, Oh My!

16 March 2007, Friday 12:25 P GMT-06

Switch to digital TV to start in October

16 March 2007, Friday 7:46 A GMT-06

Is the Ice Ready? No, Its Still To Hot To Use...

16 March 2007, Friday 7:43 A GMT-06

MIT Entire Curriculum At disposal of e-learners

6 March 2007, Tuesday 11:52 A GMT-06

A cure for e-mail attention disorder?

2 March 2007, Friday 12:51 A GMT-06
Tags:  

Windows-on-Mac software gets virtualization update

1 March 2007, Thursday 5:08 A GMT-06

EnterpriseDB is/n't Open Source

1 March 2007, Thursday 3:37 A GMT-06

BitTorrent download portal debuts

27 February 2007, Tuesday 9:05 A GMT-06

$45b TXU buyout

27 February 2007, Tuesday 9:02 A GMT-06

iPhone Competitors Got The Touch

26 February 2007, Monday 3:43 A GMT-06
Tags:        

HTC - Smart Mobility

25 February 2007, Sunday 4:22 A GMT-06

Hard to find 1-800 numbers

23 February 2007, Friday 8:35 A GMT-06

Cuba Embraces Open-Source Software

21 February 2007, Wednesday 3:10 A GMT-06

Vista at the tipping point, Err Dipping Point?

11 February 2007, Sunday 11:11 A GMT-06
Tags:  

PostgreSQL Open Source And Persistence

3 February 2007, Saturday 10:32 P GMT-06

Blackboard Pledges No Patent Blocks

3 February 2007, Saturday 10:28 P GMT-06

UVU

5 January 2007, Friday 11:58 P GMT-06

Open-source IP PBX software appliance"

4 January 2007, Thursday 3:44 A GMT-06

Asterisk an under-appreciated Open Source Success Story

4 January 2007, Thursday 3:43 A GMT-06

Open Source AJAX Tooling

4 January 2007, Thursday 3:41 A GMT-06

Google MAIL API Secuirty Alert

1 January 2007, Monday 7:37 P GMT-06
Tags:    

United States Patent Application: 0060288329

26 December 2006, Tuesday 4:00 A GMT-06

LinkBlog Popular Tags

                                       







Quick & Dirty Periodic Backup In Windoze

posted 13 March 2010, Saturday
 
Implementing a periodic backup strategy for word documents, spreadsheets, notes, images, photos or any other files or directory of files of interest is available to Windows users.  Simply implementing a batch file that copies the file from one location to another and utilizing the Windows Schedule Task facility can accomplish this task.  
 
Let's take a quick use case, you have a spreadsheet that is used for some type of data updated daily.  Backing up this file at the end of the day is the primary requirement.  Further, having the ability to keep a backup separately for review, in its original content, is a the secondary requirement.  The last requirement suggests a naming convention for the back up file to refer to a specific day's backup from another.  This can simply be resolved by a naming convention.  The file name backup could simple be named based on date and time to achieve a unique name.
 
The example we'll use here is a backup of an ordinary spread sheet.  Each backup will be saved to a specific directory with a unique file name composed of Date+Time+FileName.xls.  Further, the backup will occur every day at a specific time.  The way we implement this operation will be conducted through the Windows Schedule Task facility and a common batch file.  
 
In order to instruct the Window Scheduler to run a task we must implement a batch file to create the unique backup file name and copy the spreadsheet to the backup directory.  The only complication that we have here is the unique file name.  The quickest solution to this is to base the file name on date + time + the filename.  This can be done simply in DOS.
 
Lets create a date string with out the "/" or "-"
 
set myTargetFileDate=%date:~0,3%%date:~4,2%%date:~7,2%%date:~10,4%
 
 This would generate : Sat04012010
 
Creating a time screen with out the ":" is implemented as
 
set myTargetFileTime=%time:~0,2%%time:~3,2%%time:~6,5%
  
This generates : 145023.54
 
Now simply concatenating a filename is the next step.
 
set aTargetFileName=MyExcelFile.xls
 
Now the concatenating these variables
 set myTargetFileName=%myTargetFileDate%-%myTargetFileTime%%aTargetFileName%
 
The filename is now : Sat03012010145023.54MyExcelFile.xls
 
Now, using this method in allows the batch file to have a unique file name to utilize in any operation. With a little imagination this method could be used to create a unique directory structure, archive name or anything else that requires uniqueness. 
 
Note, this method is completely in the context of one run a day and no other operation of this sort is anticipated to be run simultaneously.  Be FOREWARNED, if you use this method for additional in tasks insure to take into account naming collisions. 
 
Now the batch file name is establish its a matter of copying the file to the backup location desired.
 
ie: copy c:\data\files\somedatefile.xls C:\data\backup\%myTargetFileName%
  
A quick batch file is created below that we can use to copy a file from one directory to another.  End result of every call to this batch file will create a new file based on date and time of execution.  This is a snapshot of the targeted file.
 
@echo off Set myFileName=MyExcel2007.xls rem echo %myFileName%
set myFileDate=%date:~0,3%%date:~4,2%%date:~7,2%%date:~10,4% 
rem echo %myFileDate%  
set myFileTime=%time:~0,2%%time:~3,2%%time:~6,5%  
rem echo %myFileTime%  
set myTargetFileName=%myFileDate%-%myFileTime%%myFileName%  
rem echo %myFileName%  
Echo BACKUP s:\fileserver\share\somespreadsheet.xls         TO  
Echo c:\backup\data\myspreadsheets\%MyFileName%  
copy c:\data\files\somedatafile.xls C:\data\backup\%myTargetFileName%  
 
Now that we have a working file setup some preliminary tasks and than setup a schedule.  
  1. Create a directory c:\data\files
  2. Create a file names someDataFile.xls 
  3. Create a backup directory c:\data\backup 
  4. Create a batch file DTStampBackup.bat  in c:\data 
First to a directory in C:\data\files and insure the spreadsheet is there.  Than do a directory of c:\data\backup this should be empty to insure everything is in order. Execute the DTStampBackup.bat to test the batch file operates correctly.  Removing the REM statements will echo the file name parts upon creation. If every thing ran correctly the backup directory there should have at least one file that is a copy of the someDataFile.xls.
 
Now let's schedule a task. . .  
 
First, going to the Windows Start Button, selecting the Control Panel and select Scheduled Tasks and click on Add Scheduled Task. This displays the Scheduled Task Wizard offering an Application for selection or a browse button.  The "Browser Button" is are interest here. Selecting "browse" use the dialog to select DTStampBackup.bat.  Next type a name of the task "Backup Some File" and select a daily to perform the task.  Select a time, try 3 minutes in the future and select every day.  
 
That should be it.  In about three minutes check the c:\data\Backup and there should be yet another file with a DateTimeStamp in the new filename.  
 
The unique name creation is the key here.  Now that its set in an environment variable the operations using the name can be include xcopy, making archives, connecting to web sites, uploading files etc... This makes things a lot better.

tags:              

links: digg this    del.icio.us    technorati    reddit