Backup Sharepoint Document Library

Don’t get all excited. This isn’t going to be anything too clever but i thought i’d share it anyway

One of our clients uses WSS (v2) in conjunction with InfoPath to do their timesheets.

We were asked how you would go about recovering the timesheets from a backup.

I explained that we’d probably have to restore the site to a temporary site then move the files we needed from the restored document library to where it belongs (if someone knows an easier way please let me know?!)

The client wanted to know if there was an easier way of doing this so i came up with a vbscript that grabs all the xml files and copies them to a folder. As i said at the start, this solution isn’t clever so if your looking to use this to backup other document types (word documents for example) it’s not going to bring any of the metadata with it

The script connects to the document library via a UNC path and just treats it like a file share

For this to work you need to make sure the WebClient service is running (if you get an error message that says something like “workstation driver is not installed” just restart the computer and you’ll be fine)

If your going to schedule this you should probably add some code that maps a network drive to the share instead of accessing the UNC directly (only way i can think of passing credentials?)

So heres the script….

Dim myFSODim DocLib

Dim TimeSheet

Dim BackupTo

Dim dayWeek

Dim FullDay

Dim LibraryPath

Dim BackupPath

 'Setup Variables

'Ensure BackupPath ends with a \

LibraryPath="\\companyweb\TimeSheets"

BackupPath="E:\Time Sheet Backups\"

dayWeek = DatePart("w", (Date))

Select Case dayWeek

Case 1

    FullDay = "Sunday"

Case 2

    FullDay = "Monday"

Case 3

    FullDay = "Tuesday"

Case 4

    FullDay = "Wednesday"

Case 5

    FullDay = "Thursday"

Case 6

    FullDay = "Friday"

Case 7

    FullDay = "Saturday"

End Select

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set DocLib = myFSO.GetFolder(LibraryPath)

Set BackupTo = myFSO.GetFolder(BackupPath & FullDay)

myFSO.DeleteFile BackupTo.Path & "\*.*"

For Each TimeSheet In DocLib.Files

TimeSheet.Copy BackupTo.Path & "\" & TimeSheet.Name

Next
The following two tabs change content below.
Andy Parkes is Technical Director at Coventry based IT support company IBIT Solutions. Formerly, coordinator of AMITPRO and Microsoft Partner Area Lead for 2012-2013. He also isn't a fan of describing himself in the third person.

1 thought on “Backup Sharepoint Document Library

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.