Windows Task Scheduler donesn't run my backup script

Posted on 2011-10-22
Last Modified: 2012-05-12
Dear Experts,

I have a backup scrip that should backup data from local server to a shared drive.  the script shown under the code.  under Task Scheduler i set it to run at 10:00PM, even if user not logged on.  Under Task scheduler even it shows that task was run successfully but I don't see any backed up data?  if i double click the script it will run and make a copy of my data.

any ideas?

@echo off
set Source=E:\sourcedata
set Target=Z:\backup
set CopyCMD=xcopy /d /i /r /k /c /h /e /v /y
:: See XCOPY switches explained at:
set Year=%date:~10,4%
set Month=%date:~7,2%
set Day=%date:~4,2%
mkdir %Target%\%Year%\%Month%\%Day%
%CopyCMD% %Source% %Target%\%Year%\%Month%\%Day%

Open in new window

Question by:uknet80
    LVL 39

    Accepted Solution

    You said that task is run and completed undet Task Scheduler but nothing has happened. Please check if at least folders were created. For me it looks like task runs properly but insuficient rights to do the script.

    Does scheduled task run on an account with appropriate credentials to read data from source directory and copy/overwrite it in target directory? Please ensure if that task is run on appropriate account.

    LVL 3

    Assisted Solution

    Also you may want to save the output messages to a log file.

    %CopyCMD% %Source% %Target%\%Year%\%Month%\%Day% >> logFile.txt

    Now, you can verify the log file to check if it really executed without problems.
    LVL 37

    Assisted Solution

    by:Gerwin Jansen
    You should realize that a scheduled task that runs 'even if the user is not logged on' has no rights on the shared drive (Z) in your batch file. The other thing is that Z: does not even exist when the task is triggered. I'd suggest that you use a UNC path instead of Z: and configure the scheduled task with a username and password that has access to the UNC path that is being copied to.
    LVL 3

    Expert Comment


    Author Closing Comment

    the solution was access to remove share drive:

    this doesn't work
    set Source=E:\sourcedata
    set Target=Z:\backup

    but this does
    set Source=E:\sourcedata
    set Target=\\server_IP_address\backup

    thanks for your helps

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
    by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    758 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

    10 Experts available now in Live!

    Get 1:1 Help Now