Quick and Easy Code Backup – Kick it Old School

The Problem

One of biggest pinpoints of working on a BI project is file management. Weather they are Excel, Word or other in flight reports, making a copy of your working files while you are in development or just trying new things you might want to roll back to an earlier version.

The Solutions

There are many ways to make a backup of working files quickly and painlessly. There are many tools available such as TFS, GIT or even SharePoint/Office 365, however sometimes the simple approach is the best if you just want a quick copy.

Note: I do use and recommend using TFS, GIT, and SharePoint for your main repository and development lifecycle, however there are times or projects where this is not available and you have to take things into your own hands.

The Quick Approach

Kicking it old School this DOS batch file example will create copy a directory from one location to another with a date and time stamp on the folder. You can set the STAMP to include when and how often a new directory is created. The example below will create a folder with the day you run the batch file, or you can include the hour, minute or even second.

If you run the batch file multiple times within the folder creation, lets say day as in the example, the files will be replaced. A new directory would only be created the next day, keeping your files from the last time you ran the process the day before. The example in the picture has a couple of different types, Day, Hour and Second.

The Code Example

Put this code a batch (.BAT) File:

for /f "delims=" %%a in ('wmic OS Get localdatetime | find "."') do
set dt=%%a
set datestamp=%dt:~0,8%
set timestamp=%dt:~8,6%
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%
set stamp=%YYYY%-%MM%-%DD%
xcopy "E:\BIFiles* E:\Code Backups\BIFIles\%stamp%* /Y /Q /S"
xcopy "E:\Development* E:\Code Backups\Development\%stamp%* /Y /Q /S"


I find myself doing this type of workflow on quite a number of projects. This gives you more personal control over your copies, and allows you to make changes without having to go to IT to do a restore of you files. However, remember to clean up your files after a period of time though.

Good luck and safe development !!


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.