Author Topic: CopyDB  (Read 1308 times)

cj

  • Master Geek
  • ****
  • Posts: 597
    • View Profile
CopyDB
« on: June 03, 2015, 07:12:11 PM »
SQLitening has slCopyDatabase which allows more options and others shared access.
This is just a simple  copy that locks everyone out while copying.
How long can a copy take?

#INCLUDE "sqlitening.inc"
%DisplayErrors=99
FUNCTION PBMAIN AS LONG 'sqlback.bas
  result&=CopyDB("sample.db3","sample.backup")
END FUNCTION
'
FUNCTION CopyDB(sFromDatabase AS STRING, sToDatabase AS STRING) AS LONG
  IF ISFILE(sFromDataBase)=0 THEN
     FUNCTION=53
     #IF %DEF(%DisplayErrors)
     ? "Source file is missing" + $CR + UCASE$(sFromDatabase),%MB_SYSTEMMODAL,FUNCNAME$
     #ENDIF
     EXIT FUNCTION
  ELSE
    slopen sFromDatabase    'open source database
    slexe "begin immediate" 'lock others out
    FILECOPY sFromDatabase,sToDataBase
    FUNCTION = ERR
    slexe "end" 'unlock source database
    slClose     'close  source database
    #IF %DEF(%DisplayErrors)
    IF ERR THEN ? ERROR$(ERR),,FUNCNAME$
    #ENDIF
  END IF
END FUNCTION

Fredrick Ughimi

  • Master Geek
  • ****
  • Posts: 495
    • View Profile
    • Software Development Company
Re: CopyDB
« Reply #1 on: August 19, 2017, 09:16:45 AM »
Hello CJ,

Is it possible to backup a db in remote mode outside the use of SQLiteningServerMonitor?

I tried your DBCopy routines and I got the usual error -8 Access Denied.

Best regards, 
Fredrick O. Ughimi

fughimi@yahoo.com
- Freedom lies in being bold -- Robert Frost, Poet