SAMS came up with a great SharePoint backup automation tool with their SPSiteBackup.wsf windows script file - it is good, but needed a couple things... so I added them...
The SAMS backup utility is really pretty great. It runs backups on all of your site collections on a given site as well as as logging the results and emailing the logs to users. This is very useful, but it is lacking a few features that I felt it needed.
First of all, the backup utility put all of the backup files into one directory. When you have a lot of sites, not to mention if you are backing up MySites, this can become a massive chunk of data. If you are running this script on any recurring basis, it just turns into a non-decipherable mess of hundreds and hundreds of files, no organization whatosever. I made a change here that will automatically make folders (named by date) and place the backups in the properly dated folder.
Second, there is no garbage collection. If I ran the script every day, I would eventually choke out all of my storage and be stuck with 100s of GBs of backups. I could just go in and delete them manually, but no one wants to do that (so 90s). What if I forget, or go on vacation, or leave
- so, I made a garbage collection method run within the script as well.
All you need to do is place the script file directly on your C: drive, customize the batch file (explanation provided within the .bat file) and schedule it to run (or run it manually) and you are running maintenance-free automatic backups on your SharePoint server/farm.
Ok, if you feel ok on your own now, stop reading - if not, read on for a step-by-step tutorial on how to schedule the automated backups on your server...
Get the backup script files ready
- Copy the 2 files from the .zip file to the machine you want to run backups on directly to the C: drive
- Open spBackup.bat in a text editor, you will see the following:
cscript c:\spBackupScript.wsf
/virt:"http://your_sp_site"
/path:"path_for_backups"
/smtpserver:"YOUR_SMTP_SERVER"
/reportto:"send_reports_to@this_email.address"
/holdfor:"number_of_days_before_backups_are_deleted(integer)"
- Change the input variables to what you need them to be (self-explanatory) for that server instance.
Now that is set up, you need to schedule the job.
- Click Start->Programs->Accessories->System Tools->Scheduled Tasks
- Double-click Add Scheduled Task, choose Next
- Click Browse... and browse to the .bat file you just edited (C:/spBackup.bat)
- Name the task and choose how often to perform the task click Next
- Choose the start time click Next
- Enter your password click Next
- Click Finish
It's just that easy, you are now making and cleaning up backups automatically. Here it is one more time:
Automated_SP_Backup.zip (3.60 kb)