You are viewing limited content. For full access, please sign in.

Question

Question

Automate Laserfiche Backup using Batch Script without disabling user access to repository at backup stage.

asked on April 30, 2014 Show version history

I just wanted to share the backup script/process I created for our environment to assist new users who are looking for solutions/answers on how to do a backup and automate it while leaving the repository open and accessible by end users during the backup process. Please feel free to move this top where it might be bit more appropriate because I do not know how to post a KB sort of a post.

Process for backup [D2D2T model, will require a backup server/network location to backup data to]:


Create a .bat script put the code starting from @echo off statement to the exit statement, modify the code according to your environment, example the SQL server information, the LF server information, the Indexing/Search Server information, your backup server folder path location etc. We have separate VM's for all these but you might just have 1 server running all these instances.

VM1 = LF Server NAME
VM2 = SQL SERVER
VM3 = SEARCH/INDEX server / On your environment it might be same as VM1.

If your SQL server is not on same server as LF server, you will need to get SQL tools to execute sql query from where LF server/repository data exists. I created script to run on LF server that has the repository instead of having script on SQL server to avoid the overhead of having network to network copy for repository data.
You will need to install Microsoft® SQL Server® 2008 R2 Command Line Utilities, worked for 2012 sql server as well.
http://www.microsoft.com/en-us/download/details.aspx?id=16978

For SQL cmd, you will also need "Microsoft® SQL Server® 2008 R2 Native Client" as well also found on same page/link as above. So the two files required to be installed on LF server (if it does not run/have sql as well on same instance)will be :
sqlncli.msi and SqlCmdLnUtils.msi

Create a SQL procedure, in our instance I created a SQL Job that would run and be triggered by our BackupAllSQLDBs.sql script, if you need assistance of creating such a SQL job and the appropriate script let me know, I could share that script as well.

Basically, before the Robocopy/copy process for repo. files takes place we are making a complete SQL database backup, we are backing the repository dbs (forms,workflow,repo db etc etc all dbs associated with LF), the external tables db we have for our dynamic tables as well as reportserver backup (this is an overkill).

NOTE: You will need read/write access to all the servers/instances for the user running this script, if testing in cmd prompt make sure you run cmd prompt as administrator else this will not work.

Schedule the bat script using windows task scheduler to run on demand or on fixed schedule, please note the task must be scheduled to run in highest privilage mode and run by the user who has admin rights on all LF instances (for example admin on sql server, backup server, indexing server, LF repository server etc. etc.). In an Windows domain run it as one of the Domain Admin accounts.


If you need help with regards to how to setup a windows scheduled task check out http://windows.microsoft.com/en-ca/windows-vista/automate-tasks-with-task-scheduler-from-windows-vista-inside-out

PS: copy and paste in a text file and rename the .txt file extension to .bat, if you are not sure how to create a batch/bat file.

Breakdown of SCRIPT:
1. Sets the Vol_flags to 39 (read only state) on the SQL server. 38 is read-write state of a volume.
2. Stops and starts the LF server (setting state to read only on sql alone will not do anything unless LF server is aware, also this makes sure that clients connections are reset).
3. The Indexing/Search server needs to be in stop state (else you will not be able to copy the files from the SEARCH folder). The users can still access the repository but will not be able to search or import/delete data.
5. Once indexing/search is stopped we are executing a sql script that backups up all the SQL datases assoicated with LF instance to our backup server.
4. Robocopy comes by default on most windows server instances after 2003 windows era, and the flags are set here to only copy newer files, so next time it runs the backup will be faster as it will only copy newer/modified files only.
5. After copy has finished the SQL vol_flags will be set to read-write state and the services/server of LF restarted.

You can now backup the data dumped to your backup server to offsite location or on a tape if you wish. We use the D2D2T backup model.

Bat SCRIPT below start copying from @echo off statement all the way to the exit statement.

@echo off
sqlcmd -S VM2 -Q "update [YourSQLREPOSITORYDB].[dbo].[vol] set vol_flags=39 where vol_flags=38" -o C:\LFScripts\logs\SQL_logreadmode.txt
timeout /T 5
sc \\VM1.YourDomain stop Lfs > C:\LFScripts\logs\LFServerReadOnlyStop.txt
timeout /T 5
sc \\VM3.Yourdomain stop LfFTSrv > C:\LFScripts\logs\LFSearchReadOnlyStop.txt
timeout /T 5
sc \\VM1.YourDomain start Lfs > C:\LFScripts\logs\LFServerReadOnlyStart.txt
timeout /T 5
sqlcmd -S VM2 -i C:\LFScripts\BackupAllSQLDBs.sql -o C:\LFScripts\logs\SQL_logbackupstatus.txt
timeout /T 5
robocopy D:\YourLaserficheRepoVolumePath \\YourBackupServerPath\LFBackups\RepoBackups /copyall /e /r:1 /w:30 /dcopy:t /xo /log:C:\LFScripts\logs\LFRepoCopy.txt /np /fp /tee
timeout /T 5
sqlcmd -S VM2 -Q "update [YourSQLREPOSITORYDB].[dbo].[vol] set vol_flags=38 where vol_flags=39" -o C:\LFScripts\logs\SQL_logWritemode.txt
timeout /T 5
sc \\VM3.Yourdomain start LfFTSrv > C:\LFScripts\logs\LFSearchReadOnlyStart.txt
timeout /T 5
sc \\VM1.YourDomain stop Lfs > C:\LFScripts\logs\LFServerWriteOnlyStop.txt
timeout /T 5
sc \\VM1.YourDomain start Lfs > C:\LFScripts\logs\LFServerWriteOnlyStart.txt
timeout /T 5
exit

 

 

Just a small update (depends on user preference). Instead of marking SQL vol to read only first, felt that the two services should be stopped prior to marking sql as read only.

So put this :

sc \\VM1.YourDomain stop Lfs > C:\LFScripts\logs\LFServerReadOnlyStop.txt
timeout /T 5
sc \\VM3.Yourdomain stop LfFTSrv > C:\LFScripts\logs\LFSearchReadOnlyStop.txt
timeout /T 5

 

before the code

sqlcmd -S VM2 -Q "update [YourSQLREPOSITORYDB].[dbo].[vol] set vol_flags=39 where vol_flags=38" -o C:\LFScripts\logs\SQL_logreadmode.txt
timeout /T 5
 

 

Also Robocopy has /purge option so instead of using /xo if you wish to have identical copy (purge deletes files/folders that do not exist anymore on the source).

 

So the code for robocopy would be something like this :

 

robocopy D:\YourLaserficheRepoVolumePath \\YourBackupServerPath\LFBackups\RepoBackups /copyall /e /r:1 /w:30 /dcopy:t /purge /log:C:\LFScripts\logs\LFRepoCopy.txt /np /fp /tee

 

4 0

Replies

replied on October 6, 2015

Thanks Sumeet Sheoran. This works really well. 

Do you have anything that would restore the repository and db in a script?

0 0
replied on January 15, 2016

Sorry Jonathan we have been fortunate to not have the need to restore anything, but I have a clone/identical testing/development environment which I can restore to if need be ever. But the restoring feature from recycle bin has been a great feature of LF product.

 

Restore script should look similar as above (provided its a fresh/complete/full restore), as long as the SQL gets restored properly, because SQL and files both need to be in sync, and you might want to not put the system into live state while restoring :p.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.