On Tue, Jul 21, 2009 at 10:07:38AM +0200, Henrik Sarvell wrote:
> That's it, dbgc and cron jobs, that rings a bell. Can you post an
> example usage of dbgc?


Usually I have a crontab entry for that application's user. It calls a
nightly backup routine, e.g. at 1:12 o'clock:

   12 1 * * * ./p lib/http.l -'client "localhost" 12300 (pack "app/back.l?*PW=" 
(pw))' -bye

12300 is the GUI port where that application is listening. So this line
will connect to the server and invoke "app/back.l", passing the password
in a local file ".pw". The reason for this password magic is that no
non-local process can start the backup.

The first statement in "app/back.l" is

   (unless (= *PW (pw))
      (quit "back.l" *PW) )

It quits immediately if the password does not match. Then it loads the

   (load "lib/too.l")

Logging is done to standard error (which is redirected to a log file):

   (out 2
      # Timestamp
      (prinl "+ Backup " (stamp))

      # Terminate all
      (tell 'bye 2)

This causes all sibling processes to be stopped, in case some users are
still working ;-)

Then the database is exclusively locked:

      (when (lock)
         (quit "Can't lock DB" @) )

and a low-level check is done:

      # Check integrity
      (for (F . @) *Dbs
         (when (dbck F)
            (quit "DB Check" (cons F @)) ) )

The database is saved in tar file(s):

      # Backup
      (call "sh" "-c" "tar cfz app$(date +%a).tgz db/app/")

Now the garbage collector is called

      # Garbage collection
      (when (dbgc)
         (println 'dbgc @) )

After that, usually some other maintenance tasks are performed, like
updating data, sending mails to users about daily tasks etc., and
"app/back.l" terminates (because of the -bye one the command line).

      # Exit
      (prinl "- Backup " (stamp)) )

- Alex
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to