Monday, July 13, 2009

Backup/restore a MediaWiki

In certain situations, you may want to backup wiki repository, e.g, for future server migration or switch to another machine. Here are guidelines to backup a MediaWiki and restore it.
Before that let's make couple of assumptions
  • Wiki database name - foo
  • Wiki database username - tim
  • Wiki database password - lyfavour
1) backup wiki database with below mysql command
mysqldump --database foo -u tim -plyfavour --add-drop-table --single-transaction -B > $(date +%Y%m%d).sql
2) copy images, settings and skins and compress them with database backup file into a single zip file
zip -r ./backup/$(date +%Y%m%d).zip /rtpc/www/wiki/images/ /rtpc/www/wiki/extensions/ /rtpc/www/wiki/includes/ /rtpc/www/wiki/skins/ LocalSettings.php $(date +%Y%m%d).sql -x backup/

Now let's take some steps to recover the wiki
  • Decompress backup file
  • Copy $(backup)/skins to $(new_wiki)/
  • Copy $(backup)/extensions to $(new_wiki)/
  • Copy $(backup)/images to $(new_wiki)/
  • Copy $(backup)/includes to $(new_wiki)/
  • Copy $(backup)/$db to /var/lib/mysql/$(new_wiki_db)
  • Repaire search index in mysql environment with
  • mysql> use $(new_wiki_db);
  • mysql> check table searchindex;
  • mysql> repair table searchindex

Configure MediaWiki-1.5.8

1. Mediawiki在配置的时候需要PHP和mysql,确保mysql运行起来(etc/rc.d/init.d/mysqld start)在配置wiki的时候不要指定mysql root的密码,因为缺省mysql的root密码是空的,除非你指定了root密码
2. 安装完Mediawiki后,在config目录下会产生LocalSettings.php这个文件,你需要把这个文件拷贝到Mediawiki的根目录
3. 如果要使能upload,就需要修改LocalSettings.php,把wgDisableUploads 设为false,同时要把wiki根目录下的images目录设置为可写
4. wiki的logo存放在skins/common/images/wiki.png文件中,每一种风格的页面都有一个php文件对应,如Monobook.php
5. 在includes/Defaultsettings.php中可以指定具有哪些后缀名的文件可以上载,哪些后缀名的文件不可以上载
6. wiki的背景图片由每一种风格的main.css来指定,名字为headbg.jpg直接把指定背景图片的这行注释掉就可以去掉背景图片
7. 在1.5以后的版本中,可以通过找到special page中的sidebar page(Mediawiki)来修改navigation bar中的内容
8. 在1.5以后的版本中,通过设置DefaultSettings.php中的wgGroupPermissions来设置是否可以匿名编辑

Wednesday, July 1, 2009

TortoiseCVS over SSH

It is fairly easy to configure TortoiseCVS working in SSH mode, choose :ext: option instead of :pserver: option in Protocol section. But to avoid type the SSH password repeatedly, we better to create the public/private key pairs for TortoiseCVS. It comes down to 3 steps:

Step 1

Use PuTTYgen application to generate public and private key, just keep all settings as default, i.e., SSH-2 RSA, 1024 bits key. After clicking "Generate" button, you shall be able to save your public key and private key. Please save your private key to a secure place, well we need to adjust the public key a little bit, original public key file looks as below

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20090702"
AAAAB3NzaC1yc2EAAAABJQAAAIEAgvAZDLz116oJ7kHEMTUpCuRuCcBPvlUnTw4hGbjINXOvMDe3VYY0YeU6pR00oEsj9JzpZw/1Sa1H3nI2XB+e0wwv2m54NllhEb1U/c7kzfW5ODU1jEdrJonf1eXGhi8nc9NnBYf6pkpUNH7mg+sIaV+Fr+uVnqFzC4mHsZqEscc=
---- END SSH2 PUBLIC KEY ----

Please change it to

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAgvAZDLz116oJ7kHEMTUpCuRuCcBPvlUnTw4hGbjINXOvMDe3VYY0YeU6pR00oEsj9JzpZw/1Sa1H3nI2XB+e0wwv2m54NllhEb1U/c7kzfW5ODU1jEdrJonf1eXGhi8nc9NnBYf6pkpUNH7mg+sIaV+Fr+uVnqFzC4mHsZqEscc=

Note: make sure all characters are in single line.

Step 2
Upload public key file to CVS server, in my case, I uploaded it to $home/.ssh, and append to the existing authorized_key with following command in my server machine:
cat public.ppk >> authorized_keys

Note
: please change mode of .ssh folder to 700 and mode of authorized_keys to 600 otherwise you get "server refused our key" error upon login

Step 3
Ok, now you have a valid private key and public key set up, please test it with plink, make sure you load the correct private key file via Pageant, then issuing the command in my client machine
plink cvs_server_address

The server shall prompt you for input the username, after that, it shall log you in automatically without asking for a password. Otherwise you shall check above steps.

There is one guideline from TortoiseCVS