In the previous two articles I have covered off how to backup your servers to one file share and script a scheduled task to automate the process. Now what we have to do is copy the backup.bat out to each C: drive of every server, and create our scheduled task on each server.
There are many reasons I have decided to do this process manually. Leaving the backup.bat on the c: drive will allow for easy maintenance of the backups on each server for adding/removing backups. The second reason is the servers you wish to backup will need different drives backed up!
Once you have copied the custom backup.bat to the c drive of all your servers its now time to schedule the task…this is a simple and painless script that can also be reverse engineered to delete the job.
Place all your server names in a text file called servers.txt one per line and place it to the c: drive root e.g. c:\. Once created, kick off a CMD prompt as a user with admin rights on the servers.
Now using the for command:
FOR /F “tokens=* delims=: ” %%i in (c:\servers.txt) do schtasks /create /s \\%%i /u domain\username /p password /tn Server-Backup /tr “c:\backup.bat” /sc daily /st 19:00:00
This will contact each server, one by one, and create your schedueled task to run every day at 7pm. Make sure to change the domain username and password to match your own environment.
Agus sin é.
As part of an ntbackup script i began recently, I needed to look at how to schedule tasks from remotely. I had some experience using at.exe but seeing as schtasks seems to be the new tool i decided to give it a lash.
Almost immediately i ran into problems, if i was to specify a username and password for the job to run as, the script demanded a system name… why ask for a system name if you want to run it locally i wondered, but with using the %computername% variable it allowed me to run this locally.
schtasks /create /s \\%computername% /u domain\username /p Password /tn Server-Backup /tr “c:\backup.bat” /sc daily /st 09:00:00
the above schedules backup.bat to run as whatever user you specify, it will display as “Server-Backup” in scheduled tasks and will run daily for ever.
Below is an example of what you should see in scheduled tasks:
Check the next post for information on how to roll this out to multiple servers.
Nt backup isn’t pretty, it can be a little temperamental and requires you to keep on top of it at all times… but so is every other product on the market.
I have chosen to keep a network location for all the backups you will create for your servers, this will aid in organizing log files, and backing up each daily backup from one resource. There are so many options available, with incremental s, dailies, full and shadow copies i have decided to keep it simple with full backups daily, but once you have an idea of how the script works theres nothing stopping you from configuring it to suit yourself.
To kick off the guts of this three parter I’ll start with writing the script you will need to backup your infrastructure to a single disk space.