# [SOLVED]: Backup Files On Windows Shutdown



## tomohawk (Dec 29, 2009)

I am using Windows 10 Pro and I have 3 files that I want to backup when Windows shutdown is initiated.

I have done a small amount of research, but most of what I see is a command which I must initiate using a batch file.

I would like to have the copy occur as part of normal Windows shutdown.

Is this possible?

If so, I would appreciate a link to detailed step-by-step instructions, as I will need help.

Thanks,
Tommy


----------



## johnwill (Sep 26, 2002)

Have you tried using task scheduler to trigger on event ID 1074 to fire off the event?


----------



## tomohawk (Dec 29, 2009)

Thanks johnwill
I would need detailed instructions, as I'm not familiar with setting up tasks.
Tommy


----------



## Corday (Mar 3, 2010)

How to


----------



## tomohawk (Dec 29, 2009)

Corday said:


> How to


Thanks Corday.

I had read some of those articles before posting but noted that there does not appear to be a "on shutdown" option. There is an "on startup" and on specific dates/times.

So, if anybody can hold my hand for a little longer, I need to understand if this issue can be resolved in Task Manager and also what is the meaning of the steps required as described in post #2 above.

Tommy


----------



## Corday (Mar 3, 2010)

There's a script for this, but that's beyond my pay grade. Some staff members have the expertise and hopefully will post.


----------



## tomohawk (Dec 29, 2009)

Thanks for the continued support Corday


----------



## johnwill (Sep 26, 2002)

tomohawk said:


> I had read some of those articles before posting but noted that there does not appear to be a "on shutdown" option. There is an "on startup" and on specific dates/times.


Since you have Win10 Pro, why not just use Group Policy?

Open a Run prompt, type gpedit.msc and click OK
Expand Computer Configuration > Windows Settings, and select Scripts (Startup/Shutdown)
Double-click Shutdown in the right-pane
Click Add, and add a batch file that does your stuff
Test it out
You can also install GPEDIT on Windows 10 Home to enable the same features.

Enable Group Policy Editor (gpedit.msc) in Windows 10 Home Edition


----------



## tomohawk (Dec 29, 2009)

Thanks johnwill

I need help writing a script (which should run (when I choose "shutdown") as follows:-
Copy (and replace) all files from c:/folder A to d:/folder B
Tommy


----------



## johnwill (Sep 26, 2002)

Do you want to keep any files from D:/<folder> that don't appear in C:/<folder> when you do the copy? In other words, is this a *mirror *operation or a *copy*? Obviously, if it's a copy operation, the folder on D: will grow in respect the C: each time a file is deleted from C: and remains on D:.

*Mirror Operation*

DEL "D:/folder B" /s /q
XCOPY "C:/folder A" "D:/folder B" /e /c /i /q

*Copy Operation*

XCOPY "C:/folder A" "D:/folder B" /e /c /i /q


----------



## tomohawk (Dec 29, 2009)

johnwill said:


> Do you want to keep any files from D:/<folder> that don't appear in C:/<folder> when you do the copy? In other words, is this a *mirror *operation or a *copy*? Obviously, if it's a copy operation, the folder on D: will grow in respect the C: each time a file is deleted from C: and remains on D:.
> 
> *Mirror Operation*
> 
> ...


Thanks johnwill

I want to copy *all files* from C:\foldername to D:\foldername and* it will aways be the exact same files* and I want to replace the files in D:/ (not add). The number of files to be backed up will *never change* (although size will, over time).

I'm assuming a copy/replace will be faster than a deletion followed by a copy.

Regards,
Tommy


----------



## johnwill (Sep 26, 2002)

Actually, I'm not sure either will be faster. If you only replace updated files, then the plain copy will clearly be faster. Note I added the /d switch that copies only new or updated files.

XCOPY "C:/folder A" "D:/folder B" /e /c /i /q /d


----------



## tomohawk (Dec 29, 2009)

Thanks johnwill

Hopefully 2 final questions


The very first time I run this, there will be *no files* existing in D:/foldername. Will this be an issue?
I assume I copy this command into notepad, and then follow the instructions for GPE above. What extension should I use for the file (.bat?)
Tommy


----------



## johnwill (Sep 26, 2002)

No issue, it should copy new and changed files.

I'd try the copies a few times, I could have missed a switch or two. Create a batch file and run it. Delete and/or add a file or two and run it again. See if everything works as it is intended.

Yes, they are .BAT files.


----------



## tomohawk (Dec 29, 2009)

Thanks for the support johnwill

Much appreciated.

Tommy


----------



## tomohawk (Dec 29, 2009)

johnwill said:


> Actually, I'm not sure either will be faster. If you only replace updated files, then the plain copy will clearly be faster. Note I added the /d switch that copies only new or updated files.
> 
> XCOPY "C:/folder A" "D:/folder B" /e /c /i /q /d


Hi johnwill

I created the .bat file and ran it manually. I get the following message, and I don't want to have to interact at this point....
Overwrite d:folder B (Yes/No/All) 

How can I get rid of all messages and proceed?

Tommy


----------



## johnwill (Sep 26, 2002)

I missed a switch, add the */y* to the command line.


----------



## johnwill (Sep 26, 2002)

Here's a page all about XCOPY

Switches with XCOPY and XCOPY32

Since you're running under Windows, look at the XCOPY32 section.


----------

