2
Vote

write-zip files used by another process

description

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.

comments

l0r3zz wrote Aug 17, 2012 at 3:25 AM

Yes, It would be good if the files could be opened in read-only mode. Eventually I had to punt and use 7-zip. But I'd prefer to not have to load a third party package.

wrote Feb 22, 2013 at 12:51 AM

Bjoern82 wrote Jan 8, 2016 at 5:17 AM

Just stumbled across the same issue. still not fixed? what a pitty :(

wrote Jan 8, 2016 at 5:17 AM