Creating a copy of a database -- best practice? - checking email - did not come through before

Author: Charlie-gm

Posted: 2019-03-02 at 07:14:33

Ok, I haven't done this in a while, but I think I have done this a few

ways.

First, by "metadata" of the database, I assume you mean stored

procedures, maybe table triggers, database comment field?

I'll also assume you are trying to run from within an .exe (so commands

like COPY PROCEDURES TO...  and APPEND PROCEDURES FROM ... will not be

available)

So...

1) if you know the "data model" of the dbc, you can open it like a table

- then look for the metadata items you want (the stored procedure code,

trigger code, etc). Do a SCATTER MEMO NAME ... Then open the other DBC

as a table and do an APPEND FROM NAME ... After everything is copied

that way I think you will want to do a PACK DATABASE or maybe VALIDATE

DATABASE on the backup. I seem to recall doing that.

2) after you've copied all the tables, copy the "database files" with

"COPY FILE <orig> TO <backup>" - copy the dbc, dct, and dcx this way.

Again a PACK or VALIDATE database may be needed afterwards. And of

course, be careful with this, test it out, etc. But I definitely used

this approach before.

3) if you are not worried about the tables being opened at the time of

doing the backup, you could just do the "COPY FILE <orig> TO <backup>" -

that command allows paths in the from/to. Also, I think it allows

wildcards, so you could do a complete copy in 1 command. Of course, the

downside is the assumption of files being closed.

-HTH,

-Charlie

---------------------------------------------

On 2/27/2019 12:22 PM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:

I can easily do something like this:

CREATE DATABASE C:\Backup\MyDBC.dbc

OPEN DATABASE C:\Production\MyDBC.dbc

liNumTables = adbobjects(laTables,'TABLE')

for ii = 1 to liNumTables

  lcFile = forceext("C:\BACKUP\" + laTables[ii],'dbf')

  use laTables[ii]

  copy to (lcFile) database C:\Backup\MyDBC.dbc with cdx

  use

endfor

...and that would get me a copy of all of the tables with their indexes.

 Great.  But what's the easiest way to get all of the DBC meta-data

into that new Backup database copy?  I can't USE the MyDBC.dbc and do a

COPY TO as that only makes the result a DBF and FPT.

Trying to think about a good disaster recovery plan (besides using

CleverFox from Rick Schummer and Frank Perez...which is probably the

best option!) for automating backups at the client who just got that

ransomware virus.

tia,

--Mike

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/9309004b-cd50-9d5a-70b8-ef16fd0b51a9@gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2019 Charlie-gm