Well... This should handle the exclusion part. Might take a while to run, though.
Code: Select all
mysqldump -u mysqluser -p password wikidb --ignore-table=wikidb.wiki_user > wikidb.sql
Now for the users...
Code: Select all
mysql -p password -u mysqluser testwikidb -X < userselect.sql | fgrep -v "<field name=\"user_password\">" | fgrep -v "<field name=\"user_email\">" | fgrep -v "<field name=\"user_real_name\">" > users.xml
Where usersselect.sql is
Code: Select all
select user_id, user_name, user_real_name, "" as user_password, user_newpassword, user_email, user_options, user_touched, user_token from testwiki_user;
Now we need to transform it...
Code: Select all
xsltproc usertransform.xsl users.xml > users.sql
Where usertransform.xsl is
Code: Select all
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" "xsl:version="1.0">
<xsl:output method="text" encoding="utf8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="resultset">
<xsl:for-each select="row">
<xsl:text>INSERT INTO wikidb_user (</xsl:text>
<xsl:for-each select="field"><xsl:value-of select="@name" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>
<xsl:text>) VALUES (</xsl:text>
<xsl:for-each select="field">"<xsl:value-of select="." />"<xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>);
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Concatenate...
Code: Select all
cat wikidb.sql users.sql > backupwikidb.sql
Next we should probably compress it...
Code: Select all
tar cjf backupwikidb.sql.tar.bz2 backupwikidb.sql
And that should do it! (I think...)
You might have to change a couple things (obviously username and password, but also possibly the select statement; I have a rather old version of mediawiki installed).