Difference between revisions of "Backup mediawiki"

Line 1: Line 1:
 
[[Category:Website]]
 
[[Category:Website]]
 
[[Category:Development]]
 
[[Category:Development]]
 +
  
 
MediaWiki backup is composed of:
 
MediaWiki backup is composed of:
 
* Database backup
 
* Database backup
 
* Files backup
 
* Files backup
 +
 +
All the content of the blog (articles, structure, navigation, ...) is saved in database. Only the images, extensions and engine are in files.
  
  
All the content of the blog (articles, structure, navigation, ...) is saved in database. Only the images, extensions and engine are in files.  
+
You can find this backup script on my github: https://github.com/guihome-diaz/IT/tree/master/backup_mediawiki
  
  
Line 115: Line 118:
 
?>
 
?>
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
=User interaction=
 +
 +
For the user interaction, I'm using a simple HTML5 + JavaScript page.
 +
You can find everything on my github.

Revision as of 23:00, 18 January 2015


MediaWiki backup is composed of:

  • Database backup
  • Files backup

All the content of the blog (articles, structure, navigation, ...) is saved in database. Only the images, extensions and engine are in files.


You can find this backup script on my github: https://github.com/guihome-diaz/IT/tree/master/backup_mediawiki


Backup principle

As this blog is running on a shared webserver, I do not have console access. Therefore I have to use PHP, HTML and JavaScript only. No shell script or Linux command.

This is the backup principle:

Backup mediaWiki


Server backup

Useful libraries


Database backup

$backupDatabase = new Backup_Database($dbHost, $dbUser, $dbPassword, $dbName);
$status = $backupDatabase->backupTables($dbTables, $dstFolder);
if ($status) {
     // Success case
} else {
     // Error case
}


Folder compression

$z1=new recurseZip();
echo $z1->compress($srcWiki,$dstFolder);


Complete backup script

You need to adjust the *** settings *** variables.

<?php
	include('recurseZip.php');
	include('backup_mysql_db.php');
	
	
	// ##############################
	// Settings
	// ##############################

	// ***** Output folder *****
	$dstFolder = "/home/...";

	// ***** Database settings *****
	$dbName = 'myDb';
	$dbHost = 'dbServer';
	$dbUser = 'dbUser';
	$dbPassword = 'secret';
	// $dbTables = '*';
	$dbTables = "wiki_archive,wiki_category,wiki_categorylinks,wiki_change_tag,wiki_externallinks,wiki_external_user,wiki_filearchive,wiki_hitcounter,wiki_image,wiki_imagelinks,wiki_interwiki,wiki_ipblocks,wiki_iwlinks,wiki_job,wiki_l10n_cache,wiki_langlinks,wiki_logging,wiki_log_search,wiki_module_deps,wiki_msg_resource,wiki_msg_resource_links,wiki_objectcache,wiki_oldimage,wiki_page,wiki_pagelinks,wiki_page_props,wiki_page_restrictions,wiki_protected_titles,wiki_querycache,wiki_querycachetwo,wiki_querycache_info,wiki_recentchanges,wiki_redirect,wiki_revision,wiki_searchindex,wiki_sites,wiki_site_identifiers,wiki_site_stats,wiki_tag_summary,wiki_templatelinks,wiki_text,wiki_transcache,wiki_updatelog,wiki_uploadstash,wiki_user,wiki_user_former_groups,wiki_user_groups,wiki_user_newtalk,wiki_user_properties,wiki_valid_tag,wiki_watchlist";

	// ***** Folders to backup *****
	$srcWiki = "/home/...";
	$srcWikiUploadFiles = "/home/...";

	
	// ##############################
	// DB backup
	// ##############################
	$log = '';
	$backupDatabase = new Backup_Database($dbHost, $dbUser, $dbPassword, $dbName);
	$status = $backupDatabase->backupTables($dbTables, $dstFolder);
	if ($status) {
		$log .= "<p>";
		$log .= "<strong>Database backup complete!</strong>";
		$log .= "</p>";
	} else {
		$log .= "<p>";
		$log .= "<strong><span style='font-weight:bold; color:red'> Database backup failure </span></strong>";
		$log .= "<br> Please check the logs";
		$log .= "</p>";
	}
	
	// ##############################
	// Files backup
	// ##############################
	// Backup mediawiki
	$z1=new recurseZip();
	echo $z1->compress($srcWiki,$dstFolder);
	// Backup wiki related files
	$z2=new recurseZip();
	echo $z2->compress($srcWikiUploadFiles,$dstFolder);	
	
	$log .= "<p>";
	$log .= "<strong>Files backup complete!</strong>";
	$log .= "</p>";

	echo $log;
?>


User interaction

For the user interaction, I'm using a simple HTML5 + JavaScript page. You can find everything on my github.