Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: ROBOCOPY - Create Backup Script

10 Dec 2012   #180
acornada

Windows 7 Home Premium SP-1, 64-bit
 
 

I don't know what you mean about having Robocopy copy a linked folder. Robocopy won't traverse an HTML URL to copy a folder; you must enter the location of the folder you want Robocopy to copy.

Show your Robocopy code.


My System SpecsSystem Spec
.
13 Dec 2012   #181
KKP

Win7 32 Bit
 
 

Hi
Thanks for the reply.
I will explain what i want to do ..

I have a saved HTM file in my source folder and i want to use a batch file to copy this file to destination folder. When the HTM file is saved there will be folder created automatically. Now when i manually copy either the HTM file or the folder, the other one get copied automatically.

Same way i want to use batch file and copy the HTM file (the user will provide the file name to be copied). requirement is that the associated folder should also be copied along with the HTM file.

When i use COPY / XCOPY command , only the HTM files is getting copied.

i used this code where %1 will be the file name i want to copy
xCOPY %1 "C:\dst\"
My System SpecsSystem Spec
14 Dec 2012   #182
acornada

Windows 7 Home Premium SP-1, 64-bit
 
 

COPY and XCOPY are not Robocopy commands. COPY and XCOPY are each separate applications, so you haven't been using Robocopy at all.

IIRC, Copy and Xcopy are essentially file copy utilities, so at their most basic would copy selected files whereas you also want to copy directories.

Robocopy will do what you want, because Robocopy is natively a folder copy application rather than file copy, so copying a folder by default includes its file contents.

You would use this format:

ROBOCOPY "source" "destination" options

For example, if your source folder is:

C:\web files

and your destination is:

C:\Backups\web backup

You could use this command line:

ROBOCOPY "C:\web files" "C:\Backups\web backup" /MIR

/MIR will MIRror a directory tree, including all sub-folders and including empty sub-folders, and of course including file contents of the source folder(s). You can add other options as required.
My System SpecsSystem Spec
19 Dec 2012   #183
DGMMikeA

Server 2008 R2 and windows 7 64-bit
 
 
robocopy over a LAN

Can you use this over a LAN connection?
I need to copy SQL .bak files from a server, using 2008 R2, to another server, also using 2008 R2 over a LAN.
Each system is on a different ip scheme and using vlans.

With this, how could this work?
I need to run this automatically every month.

I am not experienced in this, so ANY information would be grateful!

I did find the beginning tutorial very informational!!!

Thanks

Mike
My System SpecsSystem Spec
.

19 Dec 2012   #184
DGMMikeA

Server 2008 R2 and windows 7 64-bit
 
 
is this correct?

ok...

here is what I wrote but havent implemented it yet

Does it look correct?

::Source path
set sourcepath=\\10.107.145.12\"c:\program files\microsoft sql server\mssql10_50.mssqlserver\mssql\*.bak"

:destination path
set destinationpath=\\10.107.128.11\E$\"backup sql files"

::Log path
set logpath=E:\Logs\Robocopy\

::Include format yyyy-mm-dd#hh-mm-ss.ms in log filename
set filename=Robocopy_%date:~-4,4%-%date:~-7,2%-%date:~-10,2%#%time::=-%.txt

::Run command
My System SpecsSystem Spec
28 Dec 2012   #185
kqo

Windows 7 Professional x64
 
 

Hey Guys

I need help with a backup script to do backups on my laptop running Win7 Pro x64 to my Win2008R2 server.
Here is the script i wrote
@echo off
TITLE Backup program

echo Please save any open documents and then close all programs, especially Outlook.
echo off
pause

cls
net use R: /delete
goto begin

:begin
net use R: \\surulere\backup /USER:conet.com\koladapo Kq14lakoil
robocopy C:\Users\Kola R:\Kola /e /z /R:5 /W:1

echo.
echo The backup has finished.

goto done

:done
pause
if exist R: net use R: /d /y
exit


I am sorry i did not put comments to explain the script better. but the summary of what i did is
1. i delete any drives mapped to R:
2. then i map a share on my server to R: logging on with my domain username and password
3. then i use the robocopy command to copy my user folder under user/username to the mapped drive.

My problem with the program is that after running it, the script spent a whole 24HOURS! backing up the App Data. I had to stop the script from running when i got back from work the next day. The reason why i am backing up my whole User folder is because i would like to backup folders like AppData and Favorites where browser data and Outlook data files are stored.

Can anybody proffer a reason as to why the script seems to take so long backing up AppData and how i can fix the problem.

Thank you
My System SpecsSystem Spec
28 Dec 2012   #186
Golden
Microsoft MVP

Windows 7 Ult. x64
 
 

What is the size of the folder?

The /z switch is known to slow the backup speed considerably - try a test without /z to see what I mean.
My System SpecsSystem Spec
28 Dec 2012   #187
acornada

Windows 7 Home Premium SP-1, 64-bit
 
 

/Z copies in resume mode. This can slow down the process, but it also may provide a better result when copying across a network when network communication is lost temporarily. You'll have to decide if you need it or not.

If you have a multi-threaded processor, you could experiment with assigning more threads to Robocopy. While this may not make much difference for the initial copy, subsequent copies (updating the backup) can be much faster with many threads checking file attributes. e.g. /MT:32 would use 32 threads, whereas default is 8.

Also, remember that the first copy will be slow as every file must be transferred to the backup location. Subsequent copies (updating the backup) will be faster, as Robocopy will check the files and transfer only those that have changed or are new.

Why just the /E backup option? From your description, I would have thought that you would not want to store files that had been deleted from the source C: drive. If you want the backup to replicate the current state of C:, then you can use /MIR, to mirror the directory tree, the same as using /E to include even empty folders (as you have done) plus /PURGE to delete items from backup that you deleted from source. Essentially, if you want the backup to be an exact copy of the source, use /MIR.
My System SpecsSystem Spec
28 Dec 2012   #188
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Quote   Quote: Originally Posted by kqo View Post
Hey Guys

I need help with a backup script to do backups on my laptop running Win7 Pro x64 to my Win2008R2 server.
Here is the script i wrote
@echo off
TITLE Backup program

echo Please save any open documents and then close all programs, especially Outlook.
echo off
pause

cls
net use R: /delete
goto begin

:begin
net use R: \\surulere\backup /USER:conet.com\koladapo Kq14lakoil
robocopy C:\Users\Kola R:\Kola /e /z /R:5 /W:1

echo.
echo The backup has finished.

goto done

:done
pause
if exist R: net use R: /d /y
exit

I am sorry i did not put comments to explain the script better. but the summary of what i did is
1. i delete any drives mapped to R:
2. then i map a share on my server to R: logging on with my domain username and password
3. then i use the robocopy command to copy my user folder under user/username to the mapped drive.

My problem with the program is that after running it, the script spent a whole 24HOURS! backing up the App Data. I had to stop the script from running when i got back from work the next day. The reason why i am backing up my whole User folder is because i would like to backup folders like AppData and Favorites where browser data and Outlook data files are stored.

Can anybody proffer a reason as to why the script seems to take so long backing up AppData and how i can fix the problem.

Thank you
Add /XJ switch Robocopy Syntax, Command Line Switches and Examples My Digital Life
My System SpecsSystem Spec
30 Dec 2012   #189
kqo

Windows 7 Professional x64
 
 

Thank you for all your replies.
@Golden My Appdata folder is just 4.62GB. I will try it without the /z option and reply
@acornada I thought the /e option meant Robocopy should copy all subdirectories and even empty ones.
@Kaktussoft can you explain a bit better about the /XJ switch as this is the explain from the link you posted"/XJ :: eXclude Junction points. (normally included by default)."

Thank you guys
My System SpecsSystem Spec
Comment

 ROBOCOPY - Create Backup Script




Tutorial Tools Search this Tutorial
Search this Tutorial:

Advanced Search




Similar help and support threads
Windows 7 Tutorial Category
robocopy script is not working through Scheduler
Dear All, My batch file of robocopy is working fine. But when I tried to run it through task scheduler, none of the files transfer to the target location. @echo off echo +-----------------------------------------+ echo Database Export Utility for server ...
General Discussion
Robocopy Backup - ERROR 5 (0x00000005)
Hi, I'm wondering if anyone might be able to shed some light on why I am getting the following such errors when running a robocopy batch file (as administrator) which cause the backup script to stall (- albeit temporarily): I am using the following backup command: robocopy "%srcPath%\My...
Backup and Restore
How 2 create a script/BAT or something that changes my desktop image?
Okay so I just got this program called Transparent Screen Lock and you can run files when the program starts/locks and closes/unlocks. What I would like to do is create a script or something that changes my desktop background to an image when I click "lock" and another script to change the desktop...
Customization
Robocopy backup for personal folders
I have created a batch file for copying my Documents folder to an external hard drive: The log file shows that it is backing up C:\users\USERNAME\documents\My Music and C:\users\USERNAME\documents\My Pictures. That's fine, because I want those backed up anyway, but when I go to...
Backup and Restore
I Need Help To Create REG. Script With Admin. Priv. For Reg. Editor?
Hello. I have a technical question/issue I wish to ask. I hope someone can help me. I am looking help for someone to modify or rewrite for me a simple system registry script for my context menu that allows or forces to "run as administrator" privileges automatically when I click on the...
Customization
Anyone use robocopy to backup?
Evening all, Just curious to know if anyone uses the built in utility to backup software on your machine, im trying to backup my itunes folder to an external HD but having a few issues to get this to work properly! I also use sync toy for backing up but just really want to know what everyone...
Backup and Restore


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:36.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App