Solved

Need script to copy & replace a backup file on Windows PC to Windows server.

Posted on 2011-03-11
7
399 Views
Last Modified: 2012-05-11
I need a script to copy a backup file from a Windows XP computer to a Windows server 2008 by using the task manager on the XP computer....rough mapping would be...

\\UserPC\deptfile\backup\backup.bak

to

\\server\data\dept\backup\

The XP computer is on a domain with access to the server.

Also need the script to overwrite the previously backed up file on the server. Thx.
0
Comment
Question by:Wilmette
7 Comments
 
LVL 8

Expert Comment

by:jawa29
ID: 35108278
Hi Wilmette

How's this?

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\UserPC\deptfile\backup\backup.bak" , "\\server\data\dept\backup\", OverwriteExisting

Jawa29

0
 
LVL 3

Accepted Solution

by:
brd24gor earned 500 total points
ID: 35110755
Alternatively, you could have your task run this line of code without needing a script:
echo F | xcopy /y /f /i \\UserPC\deptfile\backup\backup.bak \\server\data\dept\backup\backup.bak

Open in new window

0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 35113788
Save this as a BAT file, and then create a scheduled task in Windows task scheduler to run it at the desired time and frequency.

@echo off
set CopyFile=\\UserPC\deptfile\backup\backup.bak
set DestDir=\\server\data\dept\backup
if not exist "%DestDir%\" md "%DestDir%\"
xcopy /y "%CopyFile%" "%ToDir%\"

Open in new window

~bp
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 6

Expert Comment

by:Flipp
ID: 35115942
If you need a good solid tool for this type of oPeration, then you can try Robocopy from the 2003 Resource Kit.
0
 

Author Comment

by:Wilmette
ID: 35137479
Thanks for the replies. I forgot to explain that the script will be run daily in MS Task Manager.
0
 

Author Comment

by:Wilmette
ID: 35137776
I should say...Task Scheduler not Task Manager...ooops
0
 
LVL 6

Expert Comment

by:Flipp
ID: 35142396
You can use either solution by creating an executable scripted file and then calling that file from the MS Scheduled Task.

Do you need the code for the function you requested above?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
How can this article save you time AND money?  In just a few minutes you may discover something you didn't know existed that is easy enough for you to fix yourself!
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

813 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

15 Experts available now in Live!

Get 1:1 Help Now