Link to home
Start Free TrialLog in
Avatar of rdperkins
rdperkins

asked on

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
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

you can use robocopy
To do this.

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

Carrzkiss
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.

http://ee.cffcs.com/Q_24330834/Robocopy.zip

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.

Carrzkiss
ok
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)

http://ee.cffcs.com/Q_24330834/Robocopy.zip

Good Luck
Carrzkiss
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.
http://ee.cffcs.com/Q_24330834/Robocopy.zip

(Last post, I think that I have covered everything now)
Good Luck
Carrzkiss
Avatar of rdperkins
rdperkins

ASKER

Thanks carrzkiss, will try next week at work.
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.

Suggestions?
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.

Anyway.
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.
Carrzkiss
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)?
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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,
Carrzkiss
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.
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...

Carrzkiss
Oh.
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.

Carrzkiss