write-zip files used by another process

Topics: User Forum
Oct 21, 2011 at 3:53 PM

I am new to PowerShell and am trying to create a small program to backup five database files on an hourly basis to a local drive.  (This is not the only backup solution being used.)  I am employing the write-zip cmdlet to do this and encounter errors if one of the databases is being used.  Using the command

write-zip -path $sourcepath -outputpath $targetpath -level 1

I get a message that:

"The process cannot access the file X.mdb because it is being used by another process."

This is not an issue if I first copy the files to a temp directory, zip the files and then delete, as follows:

copy-item $sourcepath $temppath
write-zip -path $temppath -outputpath $targetpath -level 1
remove-item $temppath

Although that will work easily because there are only five files being copies, it seems rather inefficient.  Is there some way to force the copy/zip of the file using the write-zip cmdlet?  I have tried including a -force in the line but it is not a recognized parameter.  Any help would be appreciated.  Thanks.

Dec 22, 2011 at 11:53 PM

I'm also seeing this problem with write-tar.

Aug 6, 2012 at 9:24 AM

any solution about it ?

Aug 17, 2012 at 1:51 AM

I'll investigate. I suspect the archive cmdlets are opening files exclusively instead of in shared / read only mode.

Aug 17, 2012 at 1:55 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.