Forum OpenACS Q&A: Backup script doesn't get sourced

Collapse
Posted by Jarkko Laine on
I changed the backup script for postgres to use scp instead of ftp. After that I placed it in the tcl directory of my OpenACS instance, according to the instructions.

However, the script doesn't seem to get sourced at server startup. There's no notice of it (nor any error related) in the server log and the backups don't get made.

I tested the script and it should be quite ok. I haven't changed any parts of the script related to scheduling the function so I guess they should be OK too.

Collapse
Posted by David Walker on
Does the user that the web site runs as have permission to that file?
Collapse
Posted by Jarkko Laine on
Yep. They're owned by nsadmin and with the same rights as other files in the tcl subdir.
Collapse
Posted by David Walker on
Make sure that the file extension is .tcl and look for the text "Backup has been scheduled." in your log file.

If you don't have that in your log file try adding "ns_log notice {beginning backup script}" at the beginning of that file and "ns_log notice {completed backup script}" to the end of it and look to see if AOLServer is starting to source your script and not finishing, or not even starting.

What version of OpenACS are you running?

Collapse
Posted by Jarkko Laine on
David,

Please see the script linked in the first message. I think it meets your requirements. There is, however, nothing related to scheduling nor making these backups in the log file. That is, I-search with "backup" in emacs doesn't give anything.

The script file has tcl extension. I have OpenACS 4.6, updated from cvs last time yesterday.

Collapse
Posted by Don Baccus on
Those instructions in the documentation were lifted from the 3.x version.  In 4.x you'll need to call it "backup-init.tcl".
Collapse
Posted by Jarkko Laine on
Thanks Don,

I renamed the file to backup-init.tcl but it didn't help, or at least there's no notice from this script when the server starts up. Here's a snippet from error log from the time of server restart. As far as I understand, server does sourcing directed in 0-acs-init.tcl and then jumps to load packages but does never source the backup file.

Collapse
Posted by Bart Teeuwisse on
How strange Jarkko,

I have no problems sourcing -init.tcl scripts in the tcl directory. See https://openacs.org/forums/message-view?message_id=66742 for an example. While it doesn't have any ns_log statements, you can easily verify that the script was sourced by visiting the filters page of the monitoring package.

/Bart

Collapse
Posted by Jarkko Laine on
Well, I'm not sure if this has anything to do with the original problem, but I installed monitoring package to track if the proc is scheduled. However, when trying to get the scheduled-procs page from Monitoring home, I just get the following error:



can't use non-numeric string as operand of "+"
    while executing
"expr { [lindex $a 5] + [lindex $a 2] }"
    (procedure "ad_scheduled_procs_compare" line 2)
    invoked from within
"ad_scheduled_procs_compare {t f {0 0} notification::sweep::sweep_notifications {-interval_id 4127 -batched_p 1} 1041855066 0 t} {f f 1800 rss_gen_serv..."
    (-compare command)
    invoked from within
"lsort -command ad_scheduled_procs_compare [nsv_get ad_procs .]"
    invoked from within
"foreach proc_info [lsort -command ad_scheduled_procs_compare [nsv_get ad_procs .]] {
    set bgcolor [lindex $bgcolors [expr { $counter % [llength $bg..."
    ("uplevel" body line 52)
    invoked from within
"uplevel {
      # /admin/monitoring/scheduled-procs.tcl

ad_page_contract {
    Displays a list of scheduled procedures.

    @author Jon Salz (jsalz..."
    (procedure "code::tcl::/web/suisse/packages/monitoring/www/scheduled-pro..." line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 7)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
$handler
      } ad_script_abort val {
# do nothing
      }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
rp_serve_abstract_file "$root/$path"
set tcl_url2file([ad_conn url]) [ad_conn file]
set tcl_url2path_info([ad_conn url]) [ad_conn path_inf..."
Collapse
Posted by Vinod Kurup on
Hi Jarkko,

I fixed that problem in the monitoring package a few days ago (on the CVS HEAD). It happened when you use ad_schedule_proc to schedule a daily or weekly proc. I think it's unrelated to your backup script not getting read.

Collapse
Posted by Jarkko Laine on
Vinod,

True, it didn't have anything to do with the problem, but now I at least can check all the scheduled procs in a simple way.

I think the problem lies in this last scheduling part of the script:

if { ! [nsv_exists acs_pgbackup scheduled_p] } {                               
    ad_schedule_proc -schedule_proc ns_schedule_daily 0 0 acs_pgbackup
    nsv_set acs_pgbackup scheduled_p 1
    ns_log Notice "Backup has been scheduled."
} 
I didn't find those nsv_* functions from aolserver api, are they possibly obsolete?

However, commenting out the if brackets didn't help the situation. I also changed the procedure definition of acs_pgbackup to ad_proc (instead of just proc), but it didn't help either.

As far as I know, the ad_schedule_proc row should be ok, and shouldn't that be the only thing that really matters?

If someone wants to check the latest version of the script as its whole, it would be totally magnificent.

The baseline still is, that not even the ns_log notice (on the last line of the script) nor any error message gets to the server log during the startup.

Collapse
Posted by Jarkko Laine on
Bart, your file's got magic in it. I copied the definition of the acs_pgbackup proc and the line that schedules it to your file and everything works like a train closet.

Oh yes, and I still can't see it as a permissions issue, at least from this information:

[nsadmin@swissnet tcl]$ ls -la
total 36
drwxr-xr-x    3 nsadmin  web          4096 tammi? 13 16:58 .
drwxr-xr-x   11 nsadmin  web          4096 tammi?  2 17:01 ..
-rw-r--r--    1 nsadmin  web          2787 joulu? 22 22:26 acs-pgbackup-init.tcl~
-rw-r--r--    1 nsadmin  web          2812 tammi? 13 16:57 backup-init.tcl
-rw-r--r--    1 nsadmin  web          3958 tammi? 13 16:58 cache-control-init.tcl
-rw-r--r--    1 nsadmin  web          1408 tammi? 13 16:01 cache-control-init.tcl~
drwxr-xr-x    2 nsadmin  web          4096 tammi? 13 16:24 CVS
-rw-r--r--    1 nsadmin  web          1451 joulu? 22 21:47 zz-postload.tcl
-rw-r--r--    1 nsadmin  web           840 joulu? 22 21:47 0-acs-init.tcl
Life is a mystery.
Collapse
Posted by Jarkko Laine on
Well, I guess there was something wrong with the old file. I saved Bart's file (where I had copied my function and its call) under another name and then deleted the extra stuff from both files.

After that, my situation was just about the same than before the tricks, i.e. two different init files. The only difference was that I this time named the backup file acs-pgbackup-init.tcl. Now everything works just fine!

Collapse
14: nsv commands and docs (response to 1)
Posted by Andrew Piskorski on
Jarrko, the nsv_* functions in AOLserver are definitely not obsolete. What do you mean, "couldn't find"? They are there, have been in all version of AOLserver since at least 3.0, I think. If they do not work in your server then something is majorly broken with your server. What version of AOLserver are you running?

If what you mean is you couldn't find the nsv_* docs, that's a different story - they're not in the same place as the ns_* docs on the AOLserver website. AOLserver's old nsv docs, (which are linked to from the AOLserver Tcl Development page) are pretty poor, and the newer AOLserver 3.5 man pages don't look any better. Perhaps they'll get cleaned up at some point for the AOLserver 4.0 man pages.

Collapse
Posted by Jarkko Laine on
Andy,
If what you mean is you couldn't find the nsv_* docs, that's a different story
That's exactly what I meant. I notice I was a bit unclear. But, as said, I found the solution to the problem hassling a bit with the init files. So I guess it had nothing to do with the code in the script file. Thanks for advice, I'll take a look at those nsv docs.