Solved

Batch File for backups

Posted on 2009-07-15
3
291 Views
Last Modified: 2013-12-01
I some batch files created for my rsync backup routine...I have it all working except 1 part.  Here is my Master batch file

Masterscript.cmd:
@Echo off
Echo Checking for Updates
Set SourceDrive=f:\backup
net use u: /d
del \\JAXBACK02\f$\backup_logs\%ComputerName%.txt
del \\JAXBACK02\f$\backup_logs\%ComputerName%_rsync.log
net use u: \\jaxback02\u$\%computername%
%~dp0\robocopy \\jaxback02\f$\backup %SourceDrive% /r:2 /w:2
call \\jaxback02\f$\backup\os.bat
Echo Central Backup started at %date% %time%
>>\\jaxback02\f$\Backup_logs\%ComputerName%.txt
Echo Central Backup FOR %cOMPUTERNAME% started at %date% %time%
>>\\jaxback02\f$\Backup_logs\%Computername%_STATUS.txt
Call %SourceDrive%\CreateShadow.cmd f: V: >>\\jaxback02\f$\Backup_Logs\%ComputerName%.txt
Echo Finished
Echo Central Backup FOR %cOMPUTERNAME% FINISHED at %date% %time%
>>\\jaxback02\f$\Backup_logs\%computername%_STATUS.txt

The sub routine os.bat:
ver > %TEMP%.\T1.DAT

FIND "Version 5.2" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto win2000
:win2000
call \\jaxback02\f$\backup\rsyncDC.bat
:end

Basically if the OS is anything but Win2k3 I need to run \\jaxback02\f$\backup\rsyncDC.bat.  
If the OS is win2k3 I need it to revert back to the Masterscript.cmd and finish processing.

I an having issues maybe withe the logic if it all..
 
0
Comment
Question by:Akostech
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
AmazingTech earned 500 total points
ID: 24860494
Put the OS check right in your masterscript.cmd. Since we're not calling the .bat file the masterscript.cmd will end.

@Echo off

Echo Checking for Updates

Set SourceDrive=f:\backup

net use u: /d

del \\JAXBACK02\f$\backup_logs\%ComputerName%.txt

del \\JAXBACK02\f$\backup_logs\%ComputerName%_rsync.log

net use u: \\jaxback02\u$\%computername%

%~dp0\robocopy \\jaxback02\f$\backup %SourceDrive% /r:2 /w:2
 

ver | FIND /i "Version 5.2">nul

if errorlevel 1 \\jaxback02\f$\backup\rsyncDC.bat
 

Echo Central Backup started at %date% %time% 

>>\\jaxback02\f$\Backup_logs\%ComputerName%.txt

Echo Central Backup FOR %cOMPUTERNAME% started at %date% %time% 

>>\\jaxback02\f$\Backup_logs\%Computername%_STATUS.txt

Call %SourceDrive%\CreateShadow.cmd f: V: >>\\jaxback02\f$\Backup_Logs\%ComputerName%.txt

Echo Finished

Echo Central Backup FOR %cOMPUTERNAME% FINISHED at %date% %time% 

>>\\jaxback02\f$\Backup_logs\%computername%_STATUS.txt

Open in new window

0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24860516
Does your robocopy work?

Some of the >> went on the next line.
@Echo off

Echo Checking for Updates

Set SourceDrive=f:\backup

net use u: /d

del \\JAXBACK02\f$\backup_logs\%ComputerName%.txt

del \\JAXBACK02\f$\backup_logs\%ComputerName%_rsync.log

net use u: \\jaxback02\u$\%computername%

%~dp0robocopy \\jaxback02\f$\backup %SourceDrive% /r:2 /w:2

 

ver | FIND /i "Version 5.2">nul

if errorlevel 1 \\jaxback02\f$\backup\rsyncDC.bat

 

Echo Central Backup started at %date% %time% >>\\jaxback02\f$\Backup_logs\%ComputerName%.txt

Echo Central Backup FOR %cOMPUTERNAME% started at %date% %time% >>\\jaxback02\f$\Backup_logs\%Computername%_STATUS.txt

Call %SourceDrive%\CreateShadow.cmd f: V: >>\\jaxback02\f$\Backup_Logs\%ComputerName%.txt

Echo Finished

Echo Central Backup FOR %cOMPUTERNAME% FINISHED at %date% %time% >>\\jaxback02\f$\Backup_logs\%computername%_STATUS.txt

Open in new window

0
 

Author Closing Comment

by:Akostech
ID: 31603796
that worked beautifully
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Robocopy questions 45 181
call multiple sqlcmd's within one bat file - with logging 9 49
Migrating From One Mac To Another 2 46
Check folder every for files and print them 5 23
By default, Carbonite Server Backup manages your encryption key for you using Advanced Encryption Standard (AES) 128-bit encryption. If you choose to manage your private encryption key, your backups will be encrypted using AES 256-bit encryption.
VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now