Go Back   vb.org Archive > Community Discussions > Forum and Server Management
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2010, 02:21 PM
BryceW BryceW is offline
 
Join Date: Feb 2006
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Turn off Forum via Shell Command Line?

I currently have a decently large forum with 56,000+ members and 2.1 million posts. This is on dedicated server and I back it up using mysqldump via SSH command line. I want to automate this process via a cron job.
Currently, I turn off the forums in the admin CP, do the mysqldump in shell then turn it back on.

Obviously, the mysqldump is easily scripted but I need a way to turn off the forums with a script, like a ssh command or something. Any suggestions, ideas?

If I dont turn the forums off, the update takes twice as long, the forums lag out and my members just sit there hitting refresh
Reply With Quote
  #2  
Old 04-07-2010, 02:34 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You will need to run 2 queries:

To turn your forums off
UPDATE datastore SET data=REPLACE(data,'s:8:"bbactive";i:1;','s:8:"bbac tive";i:0;') WHERE title='options';
UPDATE setting SET value=0 WHERE varname='bbactive';


To turn your forums on
UPDATE datastore SET data=REPLACE(data,'s:8:"bbactive";i:0;','s:8:"bbac tive";i:1;') WHERE title='options';
UPDATE setting SET value=1 WHERE varname='bbactive';
Reply With Quote
  #3  
Old 04-07-2010, 05:31 PM
kmike kmike is offline
 
Join Date: Oct 2002
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Note that the queries above will not work when one of the datastore caching modules (XCache, APC, eAccelerator, memcached) is enabled. The script must be more sophisticated - it should be able to flush memory cache for the appropriate datastore caching module.
Reply With Quote
  #4  
Old 04-08-2010, 03:27 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is a more sophisticated script:

PHP Code:
<?php
@ini_set('display_errors'0);
@
error_reporting(0);

define('VB_AREA''Maintenance');
define('SKIP_SESSIONCREATE'1);
define('SKIP_LOCATIONUPDATE'1);
define('SKIP_DEFAULTDATASTORE'1);
define('DISABLE_HOOKS'1); // You might want to comment this out if you need plugins in this script
define('NOCOOKIES'1);
define('CWD''/path/to/vbulletin');
require(
CWD '/includes/init.php');
require(
DIR '/includes/adminfunctions.php');

$db->query_write("UPDATE " TABLE_PREFIX "setting SET value = " . (($_SERVER['argv'][1] == 1) ? 0) . " WHERE varname = 'bbactive'");

build_options();
?>
I've turned off all error reporting as vB 4 seems to assume that every request comes through a webserver
(Adding yet-another bug report now ...)

Also setting the board offline does not completely kill queries so you might still run into table locking issues.
Reply With Quote
  #5  
Old 04-18-2010, 11:21 AM
BryceW BryceW is offline
 
Join Date: Feb 2006
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry its taken me so long to get back to you. But thanks alot all. I appreciate it. Hopefully thread will help others as well.
Reply With Quote
  #6  
Old 09-03-2012, 10:19 PM
zagman76 zagman76 is offline
 
Join Date: Sep 2005
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

-bump-

Sorry to bump such an old thread, but I was wondering how one could manipulate this to do the reverse - turn the forum back ON via a script.
Reply With Quote
  #7  
Old 09-17-2012, 07:55 PM
NickCat NickCat is offline
 
Join Date: Mar 2002
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by zagman76 View Post
-bump-

Sorry to bump such an old thread, but I was wondering how one could manipulate this to do the reverse - turn the forum back ON via a script.
This script does already allow for that... you just have to pass a variable it to the script.

If calling from a shell (ie straight on the server using command line) you would call it like this:

> vbscript.php (will close the site)
> vbscript.php 1 (will open the site)
> vbscript.php 0 (will also close site)

I believe you can also use these through a direct call to the file from a web browser. I'm not sure the exact formatting, but it would be similar to "yourservername.com/vbscript.php?1"

Hope that helps.

Also from a security standpoint I wound't suggest allowing something like this to be call from a web browser and only use it on the command line.

I'm integrating this into a script I use to backup my site, but we are so large I need to have the site offline in order to make the 18GB backup.

PHP Page for reference on usage: http://www.php.net/manual/en/reserve...les.server.php

argv specific section:
Quote:
'argv'
Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:33 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03828 seconds
  • Memory Usage 2,227KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete