locked
Use Robocopy for backup RRS feed

  • Question

  • Hi @ all,

    I want to do a backup of a folder at the shutdown of the computer.

    Setup:

    Source: D:\Test / Windows 10

    Target: B:\Test on a WD Mycloud

    I wrote a smal PS script:

    write-host"Test"|Out-Filed:\test.txt


    ping

    192.168.37.204|Out-Filed:\test.txt-Append


    if

    (!(Test-PathB:\))

    {

    netuseB:\\192.168.37.204\Test 

    Robocopy.exe

    D:\TestB:\/mir/r:1/w:1/log:D:\Bilder.txt|Out-Filed:\test.txt-Append

    The script is working when I am running it manually.

    I created a GPO which calls the script at shutdown and the script starts to run.

    The problem is now when running it over the GPO:

    Robocopy creates a failure

    ERROR 58 (0x0000003A) Accessing Source Directory XXXXXXXXXXXXXXXXXXXX The specified server cannot perform the requested operation

    • Moved by Bill_Stewart Monday, March 7, 2016 8:40 PM Abandoned
    Sunday, January 24, 2016 12:10 PM

Answers

  • Ok I did a work around. Created a script, named it shutdown.

    First the copy and sync job is done then shutdown -s -t 60

    Not the best way but working for me.

    • Marked as answer by Strahle_fz Tuesday, March 8, 2016 6:07 AM
    Tuesday, March 8, 2016 6:07 AM

All replies

  • That is right.  You cannot do that during a shutdown.  he network is being turned off. You cannot stop that or most other components from terminating.

    The script you posted is unreadable.


    \_(ツ)_/

    Sunday, January 24, 2016 1:45 PM
  • The script you posted is unreadable.

    What did you expect? The OP wrote "I wrote a small PS script"! (grin)
    Sunday, January 24, 2016 5:58 PM
  • The script you posted is unreadable.


    What did you expect? The OP wrote "I wrote a small PS script"! (grin)

    Oh.  A small script for a mobile phone.  I guess I need to get a bigger magnifying glass.


    \_(ツ)_/

    Sunday, January 24, 2016 6:10 PM
  • My understanding was that shutdown scripts were run synchronously (only startup scripts were default asynchronous), and that windows executes the shutdown scripts before shutting down OS components?

    If the OS shutdown was happening while the shutdown scripts were being executed, there would be massive reliability issues, and severely limited functionality.

    Source: http://blogs.technet.com/b/askds/archive/2010/03/23/group-policy-script-processing-behavior.aspx

    • Edited by Jeremy.F Sunday, January 24, 2016 9:43 PM linking to source
    Sunday, January 24, 2016 9:38 PM
  • Well - it is more complicated than that.,  You are trying to use the SYSTEM account to access network resources.  That will not usually work as expected.  Shutdown scripts sholld not access the network and they need to track errors complete or you cannot debug the issue. 

    You are getting a very obvious error.

    "Accessing Source Directory XXXXXXXXXXXXXXXXXXXX The specified server cannot perform the requested operation"

    you can try this but I doubt it wil work: https://social.technet.microsoft.com/Forums/windows/en-US/e36cdb12-1bb0-434b-975d-f5de86e9d78e/0x0000003a-the-specified-server-cannot-perform-the-requested-operation-robocopy-returns-this-error?forum=w7itprogeneral

    Here are some of the error messages:

    http://www.happysysadm.com/2011/03/robocopy-error-codes.html

    <input id="5d91f187-c82e-47a3-9adf-dceafd91c419_attachments" type="hidden" />


    \_(ツ)_/

    Sunday, January 24, 2016 10:01 PM
  • Ok I did a work around. Created a script, named it shutdown.

    First the copy and sync job is done then shutdown -s -t 60

    Not the best way but working for me.

    • Marked as answer by Strahle_fz Tuesday, March 8, 2016 6:07 AM
    Tuesday, March 8, 2016 6:07 AM