1.

Solve : Backup batch?

Answer»

I'm trying to write a little backup script that I can have automatically execute with WINDOWS scheduler. I've got it working, but I'm trying to add some validation in so it'll tell me if it fails or not. It goes a little something like this:

Code: [Select]@echo off

if exist "j:\backup\file (old).avi" (
del "j:\backup\file (old).avi"
set backup = 1) else (
set backup = 0)

if exist "j:\backup\file.avi" ren j:\backup\file.avi "file (old).avi"
xcopy "j:\fraps\file.avi" j:\backup\
if %backup% == 1 suc == ""
if %backup% == 0 suc == "NOT"
echo "File backup was %suc% successful on %time%, %date%"
echo %backup%
problem is, it doesn't work. backup isn't being populated, and it SAYS suc isn't expected.

The goal is to have this be performed on vhd's at 2am, so when i sit down int he morning I'll SEE a couple dos prompts with the status of various vhd's being backed up.

Any help would be appreciated.Quote

if %backup% == 1 suc == ""
if %backup% == 0 suc == "NOT"

You probably mean this

if %backup%==1 set suc=
if %backup%==0 set suc=NOT

Spaces matter in batch. ALSO you don't seem to understand the use of quotes. Batch language is not BASIC - you don't need to use quotes when assigning a string to a variable, unless you want the quotes to be part of the string.




Discussion

No Comment Found