Solved

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

Posted on 2013-12-18
12
3,551 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:SW111
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you Michael.
Just left the office. I will try that when I get back.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
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…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

744 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

17 Experts available now in Live!

Get 1:1 Help Now