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

06 Mar 2012   #10
mick1

Windows 7 64bit
 
 

Quote   Quote: Originally Posted by Golden View Post
Hi Mick,

Thanks for the comment. ROBOCOPY is designed to backup/copy folders to another destination (different disk, external USB drive). The idea is that if the original files are accidently deleted or damaged, you can simply copy the required from the backup location to where you need them.

If you need help setting up a robocopy script to backup your data, then let me know and I'll write one for you.

Regards,
Golden
Yes Please, this would be amazing if u can help me on this, will be waiting


My System SpecsSystem Spec
.
06 Mar 2012   #11
Golden
Microsoft MVP

Windows 7 Ult. x64
 
 

Hi,

OK. You need to let me know what you want backing up, and to where.

The easiest way is to show me some screen capture images of:

1. Your Disk Management with your USB external drive plugged in (so I can see the arrangement of your disks)
2. Windows Explorer showing me the paths and files you want to backup.

See here for help on getting me the information:

Screenshots and Files - Upload and Post in Seven Forums

Regards,
Golden
My System SpecsSystem Spec
07 Mar 2012   #12
rschaef07

Windows 7 Pro
 
 
Robocopy: trouble skipping files with "/XF"

Should the below description and robocopy script work?

I have robocopy backup scripts that just don't do what I want them to. Because I have limited exernal storage, I'm trying to exclude certain directories and file types, using /XD & /XF.
In ROBO #1 I want to mirror (/MIR) the source to the target, but exclude filetypes PDF, JPG & ZIP. I tried using "/XF *.jpg", but it didn't work with the period (.), so I removed it, but it still didn't work. I also want to exclude a variety of directoreis using /XD.
In ROBO #2, I want to back up only the jpg, pdf & zip files (& only if they are not older than 14 days), into the same folders as ROBO #1, only without the /MIR option.

ROBO #1
robocopy R:\ "E:\R.Drive\1.Tuesday" /XF *.jpg *.pdf *.zip /XD ArcJet3DSurvey xArchive Archive Inbox Temp "xSubmission Archives" "_Site Director's Shared Docs" "Nebula Modular Data Center" "*60040107 (K80017)_REDS - General" "*60046720 (K80044)_REDS8 - Repackaging" "*60176753 (K10018)_REDS - High Voltage" "*60177138 (K10033)_REDS8 Alstom Relays" "*REDS_As-Built Drawings" /MIR

ROBO #2
robocopy *jpg *pdf *zip R:\ "E:\R.Drive\1.Tuesday" /MAXAGE:14 /E

Thanks for your assistance,
Ron
My System SpecsSystem Spec
08 Mar 2012   #13
Golden
Microsoft MVP

Windows 7 Ult. x64
 
 

Hi Ron, and welcome to SevenForums,

Lets start with ROBO #2. The command should look like this:

Code:
robocopy R:\ *.jpg *.pdf *.zip E:\R.Drive\1.Tuesday /MAXAGE:14 /E
With ROBO #1, the major issue is the the use of * in the folder name (for example *60176753 (K10018)_REDS - High Voltage). Robocopy treats the * as part of the name, and of course Windows does not allow a folder to contain a * in its name. You will need to specify the top-level folder that contains all these sub-folders in the robocopy script.

However, you can still do this part:

Code:
 
robocopy R:\ E:\R.Drive\1.Tuesday /E /MIR /XF *.jpg *.pdf *. zip /XD ArcJet3DSurvey xArchive Archive Inbox Temp xSubmission Archives _Site Director's Shared Docs Nebula Modular Data Center
If you paste an image of the folder structure containing the REDS folders, it would help me work out a way to sort out these folders for backup.

Here is a little batch file that you can use to run ROBO #1 and ROBO #2. Simply copy the text exactly as it is, and paste it into an empty Notepad file, and save it on your desktop as RUN.BAT:

Code:
 
echo off
color 1E
cls
:MENU
echo.
echo ******************************
echo *** Robocopy Backup Script ***
echo ******************************
echo.
echo 1 - Run ROBO #1
echo 2 - Run ROBO #2
echo 3 - Exit
echo.
echo ******************************
echo.
SET /P M=Type 1, 2 or 3 then press ENTER:
IF %M%==1 GOTO 1
IF %M%==2 GOTO 2
IF %M%==3 GOTO 3
:1
robocopy R:\ *.jpg *.pdf *.zip E:\R.Drive\1.Tuesday /MAXAGE:14 /E
goto MENU
:2
R:\ E:\R.Drive\1.Tuesday /E /MIR /XF *.jpg *.pdf *. zip /XD ArcJet3DSurvey xArchive Archive Inbox Temp xSubmission Archives _Site Director's Shared Docs 
Nebula Modular Data Center
goto MENU
:3
pause
exit
The image below shows what it will look like when you run it. If you want something similar, or even simpler, just let me know.

Post back here if you need more help.

Regards,
Golden


Attached Thumbnails
ROBOCOPY - Create Backup Script-capture.jpg  
My System SpecsSystem Spec
.

20 Mar 2012   #14
Trapper

Windows 7 Professional 64bit
 
 

I have been trying to write a batch file so that I can copy two folders to a separate drive, and failed dismally, I then found:

Golden wrote:
Quote:
If you need help setting up a robocopy script to backup your data, then let me know and I'll write one for you.
And hope my prayers have been answered, 'cos I am probably way out of my depth with this one!!

Having very nearly lost my email folder a while ago I would like to make exact hard copy of it, not compressed or by using a 'Backup Program' (that corrupts the files)

I have an Outlook 2010 email folder;

C:\users\alanspc\My Documents\Outlook Files\ 'My email address' shown as an 'Outlook Data File' not a .pst file

I wish to copy this to my internal F:\ drive which I use only for backups. This drive is a separate HD.

Maybe it would be better to copy the whole 'Outlook Files\' in above?

I would also like to be able to only add any changes to the file that have been made like new emails which would save time, Is this called incremental backups? Whether this can be/should be done on opening or closing Outlook, or done 'as and when' manually I am not sure.

Once I have a basic idea of what I am doing I can hopefully build on it in the future. I can then copy and change the batch file to copy other folders onto my F:\ drive...

At least having something that works at the start would be a great advantage over my failures so far!
My System SpecsSystem Spec
20 Mar 2012   #15
JDobbsy1987

Windows 8.1 Pro x64
 
 

Nice Tut!

Here is a quick robocopy batch file i put together a while back, you would just have to change the actual robocopy command on line 77 to reflect the switches you would like.

The reason there is so many lines for such a simple command is because i padded it out visually a little for the people using it

ROBOCOPY - Create Backup Script-source.png ROBOCOPY - Create Backup Script-destination.png ROBOCOPY - Create Backup Script-warning.png


Attached Files
File Type: bat RoboCopy.bat (3.4 KB, 1371 views)
My System SpecsSystem Spec
20 Mar 2012   #16
Trapper

Windows 7 Professional 64bit
 
 

Hi Thanks for the reply, I have been playing with the example given in the tutorial and have tried without success to copy a test file.

This is my modified Robocopy text in Notepad:

rem --- Edit the lines below to create your own backup strategy
rem --- The /mir option has been left out for safety sake
rem --- Add more lines for each new folder requiring backup
rem --- Specified 4 threads to use for multi-threaded copying
rem --- The results of the backup can be found in my_backup_log.txt
robocopy <C:\Users\Alans PC\TEST FOLDER> <F:\Outlook Data Files> /e /np /tee /mt:4 /log:my_backup_log.txt
robocopy <source> <destination> /e /np /tee /mt:4 /log+:my_backup_log.txt
robocopy <source> <destination> /e /np /tee /mt:4 /log+:my_backup_log.txt
pause

My modified text in BOLD
This has not worked and the TEST FOLDER has not been copied to F:\Outlook Data Files, after double clicking the command on my desktop it flashes on screen for a millisecond as though it actions.

I have called my F:\ drive 'Backup (F)' according to Disk Management, would that have any bearing on my problem?
Do I need to delete the 2nd and 3rd robocopy lines?

Does the destination drive have to have the same folder name as the folder to copy? For example in the tutorial the example states:

robocopy E:\Data1 G:\Backups\Data1
robocopy F:\Data2 G:\Backups\Data2
robocopy F:\Data3 Q:\Backups\Data3
pause

Using the above do I need to name a folder in G: Backups with a sub folder called Data1?

So in Backups folder I would have a sub folder called Data1 containing the copied folder Data1. OR would the Data1 folder be copied to Backups? Thereby becoming the sub folder.....

If you see what I mean!!



I've yet to play much with DOS boxes and doing this in notepad seems more 'usual' I just need to get to grips with it.

EDIT.
I have tried with the <> removed and still not copied, I must have something fundamentally wrong. (Like my brain)
My System SpecsSystem Spec
20 Mar 2012   #17
JDobbsy1987

Windows 8.1 Pro x64
 
 

try putting quotes around the file paths

e.g.
Code:
robocopy "C:\Users\Alans PC\TEST FOLDER" "F:\Outlook Data Files" /e /np /tee /mt:4 /log:my_backup_log.txt
Regards,
JDobbsy1987
My System SpecsSystem Spec
20 Mar 2012   #18
JDobbsy1987

Windows 8.1 Pro x64
 
 

Quote   Quote: Originally Posted by Trapper View Post
Do I need to delete the 2nd and 3rd robocopy lines?
Yes, just keep:

robocopy "C:\Users\Alans PC\TEST FOLDER" "F:\Outlook Data Files" /e /np /tee /mt:4 /log:my_backup_log.txt

they are just to highlight the syntax that should be used
My System SpecsSystem Spec
20 Mar 2012   #19
Golden
Microsoft MVP

Windows 7 Ult. x64
 
 

Hi Trapper,

Unfortunately, ROBOCOPY doesn't have the ability to copy incremental portions of your Outlook file - the smallest level it will work at is the .PST file.

This is the exact command I use to backup my Outlook data files:

Code:
robocopy E:\Mail G:\Colin-PC\Mail /e /mir /mt:12
Note that I don't specify the .PST files - ROBOCOPY just backups up the entire \Mail folder (the \Mail folder actually has two .PST files in it).

If you use the pause command at the end of the script, the cmd window will not flsh and close as you describe. So, for example, you might use this:

Code:
robocopy C:\Users\Alans PC\TEST FOLDER F:\Outlook Data Files /e /np /tee /mt:4 /log:my_backup_log.txt
pause
Also, if you scan the contents of my_backup.log (located on your Desktop), it might yield some cluse as to where you are going wayward with your script. Attach it here, and I'll take a look at it for you.

Regards,
Golden
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 14:07.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App