Hi,
can anyone provide me with the appropriate .Net C# code to simply loop through all a Laserfiche server's hosted repositories and lock/unlock them. I need this to create executables that run before and after our volume backup processes.
Hi,
can anyone provide me with the appropriate .Net C# code to simply loop through all a Laserfiche server's hosted repositories and lock/unlock them. I need this to create executables that run before and after our volume backup processes.
I don't see anything in the SDK to lock the entire repository. However, you can lock the individual volumes.
var repo = new RepositoryRegistration("lfserver.name", "reponame"); var session = new Session(); session.LogIn(repo); var volumes = Volume.EnumAll(VolumeReaderOptions.LogicalOnly, session); foreach (var vol in volumes) { vol.IsReadOnly = true; vol.Save(); } volumes.Dump(); session.LogOut();
Doing it at the volume might make more sense because then you can tie your lockdown to specific paths as you back them up. For example, in our repo, we have volumes spread across multiple tiers of storage, and we could set only the tier-3 volumes to read only when tier-3 disk is going to be backed up.
Edit: You can also call the SDK assemblies from PowerShell
Add-Type -Path 'C:\Program Files\Laserfiche\SDK 10.2\bin\10.2\net-4.0\Laserfiche.RepositoryAccess.dll' $repo = [RepositoryRegistration]::new("lfserver.name", "reponame") $session = [Session]::new() $session.LogIn($repo) $volumes = [Volume]::EnumAll([VolumeReaderOptions]::LogicalOnly, $session) Foreach($vol in $volumes) { $vol.IsReadOnly = $true $vol.Save() } $session.LogOut()