Example: Directory backup with BITS cmdlets
UPDATE: This posting has been updated with a zip file that contains two versions of the script. The file "bitsbackup.ps1" is intended for use with Windows 7 RC version of BITS cmdlets and the file "bitsbackup-ctp3.ps1" is intended for use with Windows 7 Beta or PowerShell 2.0 CTP 3 version of BITS cmdlets.
-----
Here we have a sample PowerShell script for copying a directory to another UNC path. What's so special about this, you say? This scripts uses BITS PowerShell cmdlets; which means that you can backup a folder to a network location while preserving the responsiveness of other network apps.
This example is based on the Win7 beta RC version of the BITS Powershell cmdlets.
How to Use:
- Load this script by running: Import-Module <location of script>\bitsbackup.ps1
- Usage example: Backup-Directory .\myfolder \\backupserver\sharename -recurse
- This will create a copy of myfolder under \\backupserver\sharename\myfolder
- For more help: Get-Help Backup-Directory
Alex Ng [MSFT]
Comments
Anonymous
April 09, 2009
PingBack from http://microsoft-sharepoint.simplynetdev.com/example-directory-backup-with-bits-cmdlets/Anonymous
April 24, 2009
The comment has been removedAnonymous
April 24, 2009
Hi Mr. X,
- "However, I get an error message when running the import-module command in V2 CTP3 on Server 2003 R2." By default, the Import-Module cmdlet will look in your $pshomemodules directory. To import this script, you will need to give the path of the script. For example, if your script is located in C:tmpbitsbackup.ps1 then, you will need to run "Import-Module C:tmpbitsbackup.ps1". I've also re-uploaded a version of the script that should work with V2 CTP3.
- "I also can't invoke start-bitstranfer - where does this module live?" This cmdlet does not exist in CTP3. For the BITS cmdlets in CTP3, you can look at the following post: http://blogs.msdn.com/wmi/archive/2009/01/23/introducing-bits-powershell-cmdlets.aspx Hope this helps!
- Alex
Anonymous
April 24, 2009
I found have to do a "Import-Module FileTransfer", but even then, "Start-FileTransfer" referenced in bitsbackup.ps1 does not exist in PowerShell. Is there something I am missing or does this command not exist in v2 CTP3?Anonymous
April 24, 2009
Hmmm...looks like the attachment was revised after it had initially been posted and it certainly makes sense because this is now importing File-Transfer. Off to the lab!Anonymous
October 17, 2010
Another thing to be careful when importing a module is the 32/64 bit use. If for instance you are using visual studio and recieving the error "The specified module blah blah was not loaded because no valid module file was found in any module directory", it is probably because your application runs in 32 bit (under visual studio), and the OS is 64 bit. You can change it by clearly stating in the properties of your visual studio project that the target platform should be x64.