As backup for a client, can I write a script in Exchange to shut down the service, copy all the data files to another drive, and then restart the service?
You wouldn’t do that in Exchange, you’d do it with a scheduled batch file that shuts down the Exchange services.
Before I tell you how, however, let me point out that what you’re talking about doing is an “Offline” backup, which is really not the best way to do this. An offline backup doesn’t delete the log files and won’t automatically play back the residual log files in case of a disaster recovery situation.
If you’re not doing online backups, then one of two things is happening:
- Your log files are just building up and sooner or later you’re going to run out of disk space for them.
- You have circular logging enabled, which is not ideal for disaster recovery.
Ask your client how much his Exchange data is worth. If it’s not worth $430, then why bother backing it up at all?
That said, if you really want to do it, create a batch file with these lines in it:
net stop "Microsoft Exchange Event Service" /y net stop "Microsoft Exchange Internet Mail Service" /y net stop "Microsoft Exchange Message Transfer Agent" /y net stop "Microsoft Exchange Information Store" /y net stop "Microsoft Exchange Directory" /y net stop "Microsoft Exchange System Attendant" /y
Or you could just write:
net stop "Microsoft Exchange System Attendant" /ynet stop "Microsoft Exchange System Attendant" /ynet stop "Microsoft Exchange System Attendant" /y
Skip the rest of them (since they’re all dependant upon the System Attendant and will be shut down when it is). Then do your backup and Net Start them all again. But I wouldn’t. 🙂