Script for Automatic Backup then Shutdown

I need a program or script to run unattended at a certain time, such as 9:00pm, on machines with XP and Vista which will

1. Backup a select group of files to the corporate server
2. Create a "success" message or log for the desktop
3 Shutdown after backup
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne BarronAuthor, Web DeveloperCommented:
you can use robocopy
To do this.

Give me a few minutes to get all the details for you

Wayne BarronAuthor, Web DeveloperCommented:
here is a start for your.
This includes the  new windows 2003 server Robocopy.exe
This can be run on all version of windows from win2k, winxp, vista and maybe win7.

As well as a script that I made up.
As well as a readme.txt file.

I am still looking into running this and shutting down the computer afterwards.
But this will get you familuar with the Robocopy.exe and what it can do.

Wayne BarronAuthor, Web DeveloperCommented:
Updated the file with a Shutdown script
And then Readme.txt file has information in it for the Scheduling of the task.
(Look at the bottom of the readme.txt file)

Good Luck
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Wayne BarronAuthor, Web DeveloperCommented:
I had to update the file.
If you downloaded the one with the
Backup to server.cmd
With the shutdown script in it
Do not use it.

The updated one has a
Backup to server.bat

This can be run under the task manager.

(Last post, I think that I have covered everything now)
Good Luck
rdperkinsAuthor Commented:
Thanks carrzkiss, will try next week at work.
rdperkinsAuthor Commented:
I can see how this could be scheduled on a time basis, but this really needs to happen when the computer is being shutdown. I am doing more than backing up a PST file, I am first copying it to a flashdrive, then to the server, then the machine can shutdown if there are no errors.

Nothing like changing specs in mid-stream.

Wayne BarronAuthor, Web DeveloperCommented:
I did a lot of research on doing a backup during shutdown
The 1st thing that gets closed is the Network Connection during shutdown.
So as far as I know, it is not going to work.

If you know exactly WHEN the computer is going to be shutdown.
Then you can schedule the script that I provided to run during that time.

This line in the .bat file
shutdown -s -t 60
Can be changed to what ever # you want it to be.
Instead of 60-seconds.
It can be: 120, 180 or more. Or even 5-seconds.

You can add in the line of code as demostrated in the Readme.txt file.
To point to the Flash Drive as well.
So, the first thing that is done is the Flash Drive.
Then the 2nd thing that is done is the Server Backup.

>> I am doing more than backing up a PST file

I use this script to backup Gb's of information from drive to drive and drive to server drive.
This is one of the most Robust Backup scripts/software on the market that is FREE.
Before I even used Robocopy, I did a lot of testing on Paid Scripts / Programs.
And none of them gave you the flexibility that Robocopy gives to you.

If you decide to use it, great.
I am sure that you will enjoy it. I know that I love it everytime I have to do a backup.
Gb's of information speaks for itself.

Have a good one.
rdperkinsAuthor Commented:
I've been trying to consider using the task scheduler but it won't work in this case. My best bet is to put bat files on each user's desktop and require them to execute the file to shutdown. My concern is that some might not do so, and was looking for a way to automatically execute the script whenever there was a shutdown.

Also what happens in the batch file if the flashdrive is not installed, or is full (in otherwords in an error situation)?
Wayne BarronAuthor, Web DeveloperCommented:
As I mentioned before.
Once you choose to: ShutDown.
You WILL NOT be able to have access to the Network, as one of the first things to go is
Your Network Connection is closed.
This is for Security.

The only thing that I can suggest, is that if the computer have a set time to be shutdown.
Then run a Task then...

Please do the following.

Start | Programs | Accessories | System Tools | Schedule Tasks
[Add Scheduled Task]
Dialog opens.
Click [next]
Then click [Browse]
(Browse to the folder that has the .bat file for the Backup script and shutdown.)
Select the .bat file
Choose [Daily]
Then choose the time that you want it to start...
Example:  [5:30 PM]
Every Day
Start Date [4/25/2009]
Click [Next]
(Password for the users account)
Click [Next]
Then click [Finish]

This is tested, and this works.

You will have to set this up on every computer.
Maybe you could find out a way to make a script that will create this.
Not really sure, that would be another post all together.

Getting ready to go to our Anual Dogwood Festival in Fayetteville N.C..
Have a good one.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wayne BarronAuthor, Web DeveloperCommented:
How is this one going?
This is a tested script and works great for what you are doing.
I am actually using it to run networking test, and have not experianced any issues with it.

Let me know,
rdperkinsAuthor Commented:
Hi Carrzkiss,

I'm from Hickory, NC, living in Charlotte, but working in Abu Dhabi. Thanks for the script/bat. It will do part of what I need, most actually, but doesn't handle the needs of the few staff who will want to take their Outlook PST file with them. This will have to be a separate batch file they can execute before they leave work, and they can leave their machine running. Later the task scheduler can make the backup to the server then shut down. Enjoy the dogwoods and Eastern Carolina barbeque.
Wayne BarronAuthor, Web DeveloperCommented:
You are welcome.
It is always nice to see a fellow nc person in EE.

.pst file would be something like this.

(Assuming that they are using a USB drive to backup to)
(Change the locations to the proper location.
(K <-- assuming that K is the location of the backup drive))

robocopy "C:\Program Files\Office\Outlook\" "K:\Outlook Backup"  /S /V /TS /FP /LOG+:"C:\Documents and Settings\carrzxp\Desktop\Backup_Log.txt" /Z /R:10 /W:30

Good Luck in "Abu Dhabi" a long ways from home...

Wayne BarronAuthor, Web DeveloperCommented:
The dogwood fest was awesome.
Do you know who "Tisha Powell" is? From channel 11 News?
I met her on Saturday, she is a very sweet and beautiful woman.

Great weekend.
Have a good one.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.