Export and import uploads in MediaWiki

I’ve been searching for the way to export all the uploaded files in MediaWiki for about two days and now I know how to do it!

Here is the problem: the files in MediaWiki have their pages in the File: namespace. All the files are stored in images directory. The problem is that if you try to simply copy the file directory from one MediaWiki installation to another, you will not see those files in the latter. Bigger problem are the error messages you’ll get when you try to insert the file that is presented in directory but is not presented in MediaWiki database.

Here is the right way to dump MediaWiki uploads:

1. In the SOURCE wiki form the list of files you want to dump. It’s usually done with Special:AllPages page,  where you pick the namespace File. Copy the list and use some Vim magic to deal with whitespaces and tabs, turning them to line breaks:

:1,$s/\t/\r/g
 :1,$s/^\n//g

2. Suppose that the list of uploads is in the file ~/filelist on your server

3. Exporting:

php maintainance/dumpBackup.php --current --pagelist=~/filelist--uploads > ~/dmp

4. Importing:

php maintainance/importDump.php ~/dmp --uploads

I hope that was useful!

Leave a Reply

Your email address will not be published. Required fields are marked *