From Electron Cloud
Jump to: navigation, search
(Backups)
 
Line 45: Line 45:
 
#!/bin/sh
 
#!/bin/sh
 
TODAY=`/bin/date +%Y%m%d%a-%H.%M`
 
TODAY=`/bin/date +%Y%m%d%a-%H.%M`
BACKUP_DIR=/home/srutledge/backups/bugz/$TODAY
+
BACKUP_DIR=/home/backup-user/backups/server/$TODAY
 
mkdirhier $BACKUP_DIR
 
mkdirhier $BACKUP_DIR
 
cd $BACKUP_DIR
 
cd $BACKUP_DIR

Latest revision as of 16:37, 11 December 2008

Search uploaded files

Here's how to search uploaded files with swish++ (but it's been a while since I did this, so can't guarantee this is all there is to it):

if ( strstr($searchnamespaces, "6") )
{
    $mediaResults = popen("/usr/local/bin/search -c /usr/local/etc/swish++.conf -i /var/lib/swish/wiki-media.index $this->mRawtext", "r");
    $mediaResultCount = 0;
    # throw away the initial comment
    $outline = fgets($mediaResults);
    while (!feof($mediaResults))
    {
		$outline = fgets($mediaResults);
		list($rank, $fname, $fsize, $ftitle) = explode(" ", $outline, 4);
		if ($rank)
		{
			if (!$mediaResultCount)
			{
					$wgOut->addHTML("<H2>Uploaded media matches</H2><OL>");
			}
			$wgOut->addHTML("<LI><a href=" . substr($fname, 19) . ">$ftitle</a> <font size=-2>($fsize bytes) Relevance: $rank</font>");
			$mediaResultCount++;
		}
    }
    $wgOut->addHTML("</OL>");
    pclose($mediaResults);
    if (!$mediaResultCount)
    {
		    $wgOut->addHTML("<H2>No uploaded media matches</H2>");
    }
}

Obviously /usr/local/etc/swish++.conf must exist, and then you use "index" (one of the swish programs, which has an arrogantly generic name :-) to build /var/lib/swish/wiki-media.index. /usr/local/etc/swish++.conf has all the magic rules about how to extract "words" from every kind of document. Alas I seem to have lost this file. Sigh. I'll do it again someday...

Backups

On the server, as root, crontab -e and add a line like

0  1 * * * cd /path/to/backups; tar zcf mediawiki.tgz /var/www/mediawiki; tar zcf mysql.tgz /var/lib/mysql; mysqldump -ppassword wikidb > wikidb.sql; chown backup-user *"

or put that stuff in a script to run from cron.

On a backup "client" (machine which pulls backups from the server every day for safekeeping): create ~/bin/backups (below) and run it from cron:

#!/bin/sh
TODAY=`/bin/date +%Y%m%d%a-%H.%M`
BACKUP_DIR=/home/backup-user/backups/server/$TODAY
mkdirhier $BACKUP_DIR
cd $BACKUP_DIR

# copy the backups here
scp server:backups/* .

# remove backups older than 2 weeks
cd ..
find . -mtime +14 -exec rm {} \;