Warning: Undefined array key "mobile" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 352

Warning: Cannot modify header information - headers already sent by (output started at /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php:352) in /var/www/caughtinpixels.com/public_html/wp-includes/feed-rss2-comments.php on line 8
Comments on: How to create a backup script using Robocopy https://caughtinpixels.com A blog by Jacob Surland about making Fine Art Photography Tue, 24 Nov 2020 14:32:04 +0000 hourly 1 https://wordpress.org/?v=7.0 By: Jacob Surland https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-43433 Thu, 15 Feb 2018 09:09:41 +0000 https://caughtinpixels.com/?page_id=1219#comment-43433 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

In reply to jayatheertha d u.

Hi Jay,
Robocopy is “just” a program that you can launch and it will terminate when done. To relaunch it you will need a task scheduler.

From your question I can not determine how dynamic your locations are. But if you are copying from a set of folders at various times, then I would make e.g. 4 different robocopy tasks in a scheduler, each doing a specific task.

Otherwise, if your copying is very dynamic and folder names are based on for instance times, then you will have to launch ROBOCOPY from a PowerShell script or a batch shell. Use the script to set a variable with the location and then launch robocopy using the variable.

In PowerShell it will look sort of like this:

$source = YourDynamicLocation
$destination = YourOtherDynamicLocation
robocopy $source $destination -add-your-parameters-too

The specifics on the PowerShell script you will need to figure out.

–Jacob

]]>
By: jayatheertha d u https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-43430 Thu, 15 Feb 2018 05:41:55 +0000 https://caughtinpixels.com/?page_id=1219#comment-43430 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

Hello Jacob,

Nice article….

I need a clarification…

I want to schedule a robocopy scheduler job for copying updates from a different location at a specified time ( for ex everyday at 3:00AM).

can I use the robocopy options and create the scheduler ( /RH option)?

If Yes, Can you please send me a sample code?
Thanks
Jay

]]>
By: Silviu Redinciuc https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-41395 Mon, 04 Dec 2017 15:59:42 +0000 https://caughtinpixels.com/?page_id=1219#comment-41395 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

Hello,
I have a little problem. I have a simple backup script:
———–
robocopy C:\folder1 \\network_nas\Backup\folder1 /MIR /XA:H /W:0 /R:1 /REG /FFT >> C:\users\usernameX\Desktop\externalbackup.log
————-

But in log, i see this:
2017/12/04 17:55:06 ERROR 5 (0x00000005) Creating Destination Directory \\network_nas\Backup\folder1
Access is denied.

How to set credential to destination network server ? for example username, password?

]]>
By: b.t. https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-40354 Tue, 17 Oct 2017 15:58:45 +0000 https://caughtinpixels.com/?page_id=1219#comment-40354 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

All of those commands seem like an overkill. What’s wrong (if you don’t want a mirror backup–which is dangerous for networks where users delete files and then come running to the sysadmin days later that they need access to those deleted files) with something like this:

c:\robocopy.exe c:\[directory to be backed up] e:\[target directory where the files will be backed up to] /b /e /log:e:\backup_log_file.txt

ex: c:\robocopy.exe c:\home e:\ /b /e /log:e:\backup_log_file.txt

Where e:\ is the external backup drive;
c:\home is the folder to be backed up;

ymmv (your mileage may vary). . . .

P.S. Thanks for the info on scheduling. 🙂

]]>
By: Jacob Surland https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-28207 Sun, 14 Aug 2016 11:41:36 +0000 https://caughtinpixels.com/?page_id=1219#comment-28207 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

In reply to Girgoci Mihai.

I think that is not possible out of the box. You will need a folder watcher, to trigger the Robocopy script.

–Jacob

]]>
By: Jacob Surland https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-28205 Sun, 14 Aug 2016 11:40:22 +0000 https://caughtinpixels.com/?page_id=1219#comment-28205 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

In reply to Frankenstein.

Hi,
Thanks a lot it is an interesting point. I actually think about that myself. I will find a way to explain it detailed.
–Jacob

]]>
By: Frankenstein https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-28192 Sat, 13 Aug 2016 17:08:49 +0000 https://caughtinpixels.com/?page_id=1219#comment-28192 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

Nice guide, but you may want to let people know about the dangers of using MIR. If you effed up and used MIR against your on-going backup, your backup will be destroyed. Essentially you’ve created a guide for delayed manual “RAID-1”. They’re not backups, but “hardware” mirrors.

]]>
By: Girgoci Mihai https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-27688 Wed, 03 Aug 2016 18:59:12 +0000 https://caughtinpixels.com/?page_id=1219#comment-27688 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

And if you want to start the task only if I put something in the source folder ?

]]>
By: Jacob Surland https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-26883 Thu, 07 Jul 2016 10:16:53 +0000 https://caughtinpixels.com/?page_id=1219#comment-26883 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

In reply to Goulart.

Cool – and great that you share the final result 🙂

–Jacob

]]>
By: Goulart https://caughtinpixels.com/how-to-create-a-backup-script-using-robocopy/#comment-26882 Thu, 07 Jul 2016 09:21:35 +0000 https://caughtinpixels.com/?page_id=1219#comment-26882 Warning: Undefined variable $pstl_comments_number in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 43

Warning: Undefined array key "cid" in /var/www/caughtinpixels.com/public_html/wp-content/plugins/post-layout/plugin.php on line 46

Thank You! Now it is working like a charm! If someone need, there is the full script:

@ECHO ON
SETLOCAL
SET SourceDir=C:\test1
SET TargetDir=Z:\test2
SET tempFolderName=@_Copy_in_progress_DO_NOT_USE_@
SET LogFile=D:\LogPath\Logfile.txt
ROBOCOPY “%SourceDir%” “%SourceDir%\%tempFolderName%” /MOVE /NS /NP /v /W:0 /R:0 /LOG:%LogFile% /XD “%SourceDir%\%tempFolderName%”
:wait
TIMEOUT /t 5
ROBOCOPY “%SourceDir%\%tempFolderName%” “%TargetDir%” /MOVE /NS /NP /v /W:0 /R:0 /LOG+:%LogFile%
GOTO :EOF

:REPORT_ERRORLEVEL
echo.
if ERRORLEVEL 16 echo ***FATAL ERROR*** & goto :EOF
if ERRORLEVEL 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto :EOF
if ERRORLEVEL 14 echo FAIL + MISMATCHES + XTRA & goto :EOF
if ERRORLEVEL 13 echo OKCOPY + FAIL + MISMATCHES & goto :EOF
if ERRORLEVEL 12 echo FAIL + MISMATCHES& goto end
if ERRORLEVEL 11 echo OKCOPY + FAIL + XTRA & goto :EOF
if ERRORLEVEL 10 echo FAIL + XTRA & goto :EOF
if ERRORLEVEL 9 echo OKCOPY + FAIL & goto :EOF
if ERRORLEVEL 8 echo FAIL & goto :EOF
if ERRORLEVEL 7 echo OKCOPY + MISMATCHES + XTRA & goto :EOF
if ERRORLEVEL 6 echo MISMATCHES + XTRA & goto :EOF
if ERRORLEVEL 5 echo OKCOPY + MISMATCHES & goto :EOF
if ERRORLEVEL 4 echo MISMATCHES & goto :EOF
if ERRORLEVEL 3 echo OKCOPY + XTRA & goto :EOF
if ERRORLEVEL 2 echo XTRA & goto :EOF
if ERRORLEVEL 1 echo OKCOPY & goto :EOF
if ERRORLEVEL 0 echo No Change & goto :EOF

]]>