<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.wplug.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=67.207.100.128</id>
	<title>WPLUG - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.wplug.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=67.207.100.128"/>
	<link rel="alternate" type="text/html" href="https://www.wplug.org/index.php/Special:Contributions/67.207.100.128"/>
	<updated>2026-10-31T09:24:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://www.wplug.org/index.php?title=Simple_MediaWiki_Backup&amp;diff=1958</id>
		<title>Simple MediaWiki Backup</title>
		<link rel="alternate" type="text/html" href="https://www.wplug.org/index.php?title=Simple_MediaWiki_Backup&amp;diff=1958"/>
		<updated>2009-03-24T01:22:09Z</updated>

		<summary type="html">&lt;p&gt;67.207.100.128: /* backupDB.bash */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Internet Committee]]&lt;br /&gt;
&lt;br /&gt;
MediaWiki is one of my favorite pieces of software.  Not because its code is elegant (&#039;&#039;LocalSettings.php? bleh&#039;&#039;), or because it has such a succinct but useful set of features (&#039;&#039;skins!&#039;&#039;).  No, the thing about MediaWiki is that it does a great job of being a wiki.&lt;br /&gt;
&lt;br /&gt;
I&#039;m sure there has to be a better piece of wiki software out there, but I&#039;ve not yet found it.&lt;br /&gt;
&lt;br /&gt;
So, in the interest helping out other MediaWiki aficionados, here are three scripts which I use when I&#039;m doing upgrades.  This is only half the battle (the backing up half.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backup Scripts==&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* These scripts are designed for use with mysql as the backend to the wiki.  Other databases require the scripts to be adapted appropriately.&lt;br /&gt;
* There are redundancies in running [[#backupAll.bash|backupAll.bash]].  (hint: the databases).  Why?  Because when I run backupAll.bash, I want to backup everything.  I want to backup the mysql server.  I want to backup the wiki.  There could be other things in backupAll.bash, but the listing here only includes the wiki related stuff.  But, each backup should be atomic.  So, [[#backupWiki.bash|backupWiki.bash]] should backup the wiki and its dependents.  [[#backupDB.bash|backupDB.bash]] should backup the database.  I don&#039;t worry that in there the database is getting backed up (or dumped, more precisely) twice.  Better twice than not at all.&lt;br /&gt;
* So, in regards to the above bullet point, you can run [[#backupWiki.bash|backupWiki.bash]] by itself and have your wiki backed up.&lt;br /&gt;
* Why backup?  Because with a backup in hand, you can safely upgrade your wiki to the latest version, which means you install cool [http://www.mediawiki.org/wiki/Extensions extensions.]&lt;br /&gt;
&lt;br /&gt;
===backupAll.bash===&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 export scriptDir=/root&lt;br /&gt;
 &lt;br /&gt;
 if [ -z $1 ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Invalid backup label.&amp;quot;&lt;br /&gt;
  exit 1;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Backing DB up to label $1&amp;quot;&lt;br /&gt;
 echo &amp;quot;_________________________&amp;quot;&lt;br /&gt;
 $scriptDir/backupDB.bash $1&lt;br /&gt;
 echo &amp;quot;&amp;quot;&lt;br /&gt;
 echo &amp;quot;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Backing Wiki up to label $1&amp;quot;&lt;br /&gt;
 echo &amp;quot;_________________________&amp;quot;&lt;br /&gt;
 $scriptDir/backupWiki.bash $1&lt;br /&gt;
 echo &amp;quot;&amp;quot;&lt;br /&gt;
 echo &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===backupDB.bash===&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #Date:&lt;br /&gt;
 &lt;br /&gt;
 if [ -z $1 ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Invalid backup label.&amp;quot;&lt;br /&gt;
  exit 1;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 export dbUser=root&lt;br /&gt;
 export password=supersecret&lt;br /&gt;
 export mysqlSQL=mysql.$1.sql&lt;br /&gt;
 export wikidbSQL=wikidb.$1.sql&lt;br /&gt;
 export mysqlBZ2=$mysqlSQL.bz2&lt;br /&gt;
 export wikidbBZ2=$wikidbSQL.bz2&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating dump of mysql...&amp;quot;&lt;br /&gt;
 mysqldump -u $dbUser --password=$password mysql &amp;gt; $mysqlSQL&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating dump of wikidb...&amp;quot;&lt;br /&gt;
 mysqldump -u $dbUser --password=$password wikidb &amp;gt; $wikidbSQL&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 if [ -f $mysqlBZ2 ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Removing old backups of $mysqlBZ2...&amp;quot;&lt;br /&gt;
  rm -r $mysqlBZ2&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 if [ -f $wikidbBZ2 ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Removing old backups of $wikidbBZ2...&amp;quot;&lt;br /&gt;
  rm -r $wikidbBZ2&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Zipping up $mysqlBZ2...&amp;quot;&lt;br /&gt;
 bzip2 $mysqlSQL&lt;br /&gt;
 echo &amp;quot;Zipping up $wikidbBZ2...&amp;quot;&lt;br /&gt;
 bzip2 $wikidbSQL&lt;br /&gt;
&lt;br /&gt;
===backupWiki.bash===&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 if [ -z $1 ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Invalid backup label.&amp;quot;&lt;br /&gt;
  exit 1;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 export destFile=wikiBackup.$1.tar.bz2&lt;br /&gt;
 export temp=/tmp&lt;br /&gt;
 export backupWiki=backupWiki&lt;br /&gt;
 export tempDir=$temp/backupWiki&lt;br /&gt;
 export srv=/srv&lt;br /&gt;
 export mediaWiki=mediawiki&lt;br /&gt;
 export mediaWikiPath=$srv/$mediaWiki&lt;br /&gt;
 export wikiDB=wikidbB&lt;br /&gt;
 export password=supersecret&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Remove the temporary directory if it exists.&lt;br /&gt;
 &lt;br /&gt;
 if [ -d $tempDir ] &lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Removing temporary directory $tempDir...&amp;quot;&lt;br /&gt;
  rm -rf $tempDir&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # If the backup file exists, delete it.&lt;br /&gt;
 &lt;br /&gt;
 if [ -f $destFile ] &lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Removing old backup file $destFile...&amp;quot;&lt;br /&gt;
  rm $destFile&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Create the temporary directory.&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating temporary directory $tempDir...&amp;quot;&lt;br /&gt;
 mkdir $tempDir&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Get the database dumps.&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating database dumps...&amp;quot;&lt;br /&gt;
 mysqldump -u root --password=$password mysql &amp;gt; $tempDir/mysql.sql&lt;br /&gt;
 mysqldump -u root --password=$password $wikiDB &amp;gt; $tempDir/wikidb.sql&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Get the important files from mediawiki.&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating backups of settings php files and vhost...&amp;quot;&lt;br /&gt;
 cp /etc/apache2/vhosts.d/wiki.conf $tempDir&lt;br /&gt;
 cp $mediaWikiPath/LocalSettings.php $tempDir&lt;br /&gt;
 cp $mediaWikiPath/AdminSettings.php $tempDir&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Backup the mediawiki directory.&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Backing up mediawiki directory...&amp;quot;&lt;br /&gt;
 tar --create --bzip2 --directory=$srv --file=$tempDir/mediawiki.tar.bz2 $mediaWiki &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Create the master backup.&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Creating master backup $destFile from $tempDir...&amp;quot;&lt;br /&gt;
 tar --create --bzip2 --directory=$temp --file=$destFile $backupWiki &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Remove the temporary directory if it exists.&lt;br /&gt;
 &lt;br /&gt;
 if [ -d $tempDir ]&lt;br /&gt;
 then&lt;br /&gt;
  echo &amp;quot;Removing temporary directory $tempDir...&amp;quot;&lt;br /&gt;
  rm -rf $tempDir&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What a backup entails...===&lt;br /&gt;
 yoda:~ # ./backupAll.bash test&lt;br /&gt;
 Backing DB up to label test&lt;br /&gt;
 _________________________&lt;br /&gt;
 Creating dump of mysql...&lt;br /&gt;
 Creating dump of wikidb...&lt;br /&gt;
 Removing old backups of mysql.test.sql.bz2...&lt;br /&gt;
 Removing old backups of wikidb.test.sql.bz2...&lt;br /&gt;
 Zipping up mysql.test.sql.bz2...&lt;br /&gt;
 Zipping up wikidb.test.sql.bz2...&lt;br /&gt;
   &lt;br /&gt;
 &lt;br /&gt;
 Backing Wiki up to label test&lt;br /&gt;
 _________________________&lt;br /&gt;
 Removing temporary directory /tmp/backupWiki...&lt;br /&gt;
 Creating temporary directory /tmp/backupWiki...&lt;br /&gt;
 Creating database dumps...&lt;br /&gt;
 Creating backups of settings php files and vhost...&lt;br /&gt;
 Backing up mediawiki directory...&lt;br /&gt;
 Creating master backup wikiBackup.test.tar.bz2 from /tmp/backupWiki...&lt;br /&gt;
 Removing temporary directory /tmp/backupWiki...&lt;br /&gt;
&lt;br /&gt;
[[Category:Internet Committee]]&lt;/div&gt;</summary>
		<author><name>67.207.100.128</name></author>
	</entry>
</feed>