Discussion:
How to force tables to close before a backup
(too old to reply)
John Pugh
2010-05-21 04:41:02 UTC
Permalink
Hi,
I want to make sure all tables are closed before backing them up.
Initially I plan to have a timer to ask users to shut down when a backup
needs to be done.
I also want to provide for the (hopefully unusual) situation where something
has gone wrong and the tables are still open.
Could someone suggest how this can be done.

Thanks in advance,

John Pugh
Anchor Business Systems
Adelaide, South Australia
Stefan Wuebbe
2010-05-21 07:50:37 UTC
Permalink
Hi John,
Post by John Pugh
Hi,
I want to make sure all tables are closed before backing them up.
Initially I plan to have a timer to ask users to shut down when a backup
needs to be done.
That approach is working well for me. Here a Timer is watching a
shared directory for "flag" files containing messages, asks the
user for a shutdown, and if the user does not respond within a
few minutes, it does an automatic shutdown.

The semaphores/flags can either be RLock()'ed rows in a shared table
or FCreate()ed files (in order to avoid orphaned semaphores left
by eventually crashed clients).
Post by John Pugh
I also want to provide for the (hopefully unusual) situation where something
has gone wrong and the tables are still open.
Could someone suggest how this can be done.
I'd suggest to use ADbObjects() (or ADir() if there is no DBC)
in order to get all tables, and then do a "Use ... Exclusive"
attempt on each inside a Try/Catch block
Post by John Pugh
Thanks in advance,
John Pugh
Anchor Business Systems
Adelaide, South Australia
BTW, would you mind if I'd ask you an "Adelaide" question via email?



Regards
-Stefan
Beverly Howard
2010-05-21 14:30:18 UTC
Permalink
ask users <<
The timer could "ask users" then perhaps start a second timer which
could issue a "QUIT" if the user had not complied by that time.

Obviously, set some type of flag that would prevent users who
immediately restarted from getting to the point of opening any databases.

Finally, know that file/record flags/locks are passive... if the user
has files open, with or without locks, and they simply "disappear" due
to a power down or reboot, it's highly likely that their possession of
those flags will persist until they reboot and reappear.

Beverly Howard
Stefan Wuebbe
2010-05-21 15:47:33 UTC
Permalink
Post by Beverly Howard
ask users <<
The timer could "ask users" then perhaps start a second timer which
could issue a "QUIT" if the user had not complied by that time.
Obviously, set some type of flag that would prevent users who
immediately restarted from getting to the point of opening any databases.
Finally, know that file/record flags/locks are passive... if the user
has files open, with or without locks, and they simply "disappear" due
to a power down or reboot, it's highly likely that their possession of
those flags will persist until they reboot and reappear.
Not quite - an RLock() as well as a low-level file handle would both
get released when the owner of the handle "disappears".
That is, the server's Computer Management "Open Files" snap-in might
still count a client even if it has crashed, but VFP is not so shy,
in my experience <s>



hth
-Stefan
Beverly Howard
2010-05-21 20:44:55 UTC
Permalink
Post by Stefan Wuebbe
Not quite - an RLock() as well as a low-level file handle would both
get released when the owner of the handle "disappears". <<

What has changed with vfp vs foxpro? My foxpro 2.6 experience with this
had a "number incrementer" dbf as it's illustrative focal point.

Didn't happen that often, but where a user locked the record, re-read
the record, incremented the number, then flushed and unlocked the
record, _if_ the user "went away" between the lock and unlock, no one
else could increment the counter until the computer that disappeared was
rebooted.

That said, this was in a novell network environment, so, I can't speak
for other networks.

Beverly Howard
John Pugh
2010-05-23 04:28:15 UTC
Permalink
Thanks for the responses. All tables are buffered, so I think I will just
let the user know if VFP is unable to open all tables exclusively after the
timer has done its thing.

Stefan, I have sent you an email - if you don't receive it my address is
john at ab5 dot com dot au.

John
Post by John Pugh
Hi,
I want to make sure all tables are closed before backing them up.
Initially I plan to have a timer to ask users to shut down when a backup
needs to be done.
I also want to provide for the (hopefully unusual) situation where
something has gone wrong and the tables are still open.
Could someone suggest how this can be done.
Thanks in advance,
John Pugh
Anchor Business Systems
Adelaide, South Australia
Loading...