Solved

How to copy and rename folder using task scheduler in windows 2003 server

Posted on 2013-12-18
12
3,698 Views
Last Modified: 2013-12-27
I would like to schedule to copy a folder from one server to another server.
I imagine that this can be done easily with task scheduler.

My difficulty is that I need to rename the folder we are trying to copy.
For example:
Source - Server A - Folder "Backup"
Destination - Server B - Folder "Backup18Dec2013"

So basically I would like to rename the folder being copied to include the date it is being copied.

We are using WIndows 2003

Thank you in advance.
0
Comment
Question by:SW111
  • 6
  • 6
12 Comments
 
LVL 23

Expert Comment

by:Michael74
ID: 39728464
The command you need here is xcopy
http://pcsupport.about.com/od/commandlinereference/p/xcopy-command.htm

eg

Xcopy /S /I /E /H D:\data\documents E:\Newfolder\documents
http://www.windows-commandline.com/xcopy-command-syntax-examples/

Michael
0
 
LVL 23

Expert Comment

by:Michael74
ID: 39728471
You can use %date% to get the current date value

This link shows how to format the date to a suitable format

http://www.computerhope.com/issues/ch000987.htm

Michael
0
 

Author Comment

by:SW111
ID: 39728566
Thanks Michael,
but I havent figure out how to use the two command in task scheduler.

Should I run them separately:
1. tun xcopy in server A, to copy to server B
2. schedule rename in server B

or (preferably) can I run them in one go like:
1. in server A:
Xcopy /S /I /E /H D:\Backup \\Server2\ScheduledBackup\Backup%date%

Thanks
0
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 

Author Comment

by:SW111
ID: 39728638
So I've tried this and get a failed result:

Xcopy /S /I /E /H F:\Backup\testcopy\ \\DATASERVER03\Secondary Backup\testcopy-%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,
2%m%time:~6,2%s%\

Invalid number of parameters

where F:\Backup\testcopy\ is the directory I'm trying to copy

and \\DATASERVER03\Secondary Backup\ is the location inside which I would like to put the copy of source directory

and the rest, I basically copy and paste because I have no idea what they mean.

Thanks
0
 
LVL 23

Expert Comment

by:Michael74
ID: 39730763
The error is cause by spaces in the path. You need to enclose the path in double quotes to resolve this


Xcopy /S /I /E /H "F:\Backup\testcopy\" "\\DATASERVER03\Secondary Backup\testcopy-"%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,
2%m%time:~6,2%s%\

Michael
0
 

Author Comment

by:SW111
ID: 39731102
Hi Michael, still have a bit of glitch:

C:\Users\myuser>Xcopy /S /I /E /H "F:\FMP Backup\test.txt.txt" "\\DATASERVER03\FMP Secondary Backup\testcopy-"%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%t
ime:~3,2%m%time:~6,2%s%.txt
Does \\DATASERVER03\FMP Secondary Backup\testcopy-12-20-2013_@_12h22m21s%.txt sp
ecify a file name
or directory name on the target
(F = file, D = directory)? f
F:\FMP Backup\test.txt.txt
1 File(s) copied

2. BUT when I do it for a folder:

C:\Users\myuser>Xcopy /S /I /E /H "F:\FMP Backup\test\" "\\DATASERVER03\FMP Seconda
ry Backup\test-"%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,2%m%
time:~6,2%s%\
Invalid path
0 File(s) copied

So my questions are:
a. how to make it work for folders
b. how to auto choose file/directory in case 1? (I will use this with task scheduler)

Thanks
0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 39737180
Sorry for delay

The flags are specifying that we are coying a directory so we do not need to include the back slashes and when a single file is specified the message you noted appears because the system is expecting a directory but got a single file.

I have tested the following and it worked for me (X's replace actual server name)

Xcopy /S /I /E /H "C:\tmp" "\\XXXXXXXXX\Test Share\test-%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,2%m%time:~6,2%s%"

so for you it should be

Xcopy /S /I /E /H "F:\FMP Backup\test" "\\DATASERVER03\FMP Seconda
ry Backup\test-%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,2%m%time:~6,2%s%"

Michael
0
 

Author Comment

by:SW111
ID: 39741078
Michael,

That was AWESOME.
Thank you very much.

I dont understand 85% of the command, but it works like a charm.

Wish you a Happy New Year!
0
 

Author Comment

by:SW111
ID: 39741090
Uh, Michael, actually, can you help me with one more question?

How do I input this into Task scheduler in windows 2008 server?
I tried it but the argument box is not long enough to fit all the arguments...

Thanks
0
 
LVL 23

Expert Comment

by:Michael74
ID: 39741094
Copy the command into a text file and name it with the extension .bat.  You can then call this file to run.

Michael
0
 
LVL 23

Expert Comment

by:Michael74
ID: 39741096
Have a look at this article for more information on setting up the task scheduler

http://richardstk.com/2012/06/15/scheduled-task-to-run-a-batch-file/
0
 

Author Comment

by:SW111
ID: 39741360
Thank you Michael.
Just left the office. I will try that when I get back.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

697 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