Solved

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

Posted on 2013-12-18
12
3,638 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CloudBerry to Amazon for VM 3 72
Veeam backup Catalog 6 98
Which version of Microsoft Project does my client need? 3 114
Backup fail due to VSS errors. 4 110
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
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 walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

831 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