Manual:Backing up a wiki/id

Sangat penting untuk membuat cadangan wiki Anda (data dan berkasnya) secara rutin. Pada halaman ini akan dijelaskan secara umum bagaimana melakukan cadangan data wiki Anda pada MediaWiki; Untuk kebutuhan yang lebih spesifik misalnya cadangan secara periodik, Anda perlu melakukan penyesuaian tersendiri.

Tinjauan
MediaWiki menyimpan data pada dua lokasi, yaitu:
 * Database : Halaman berikut isinya, pengguna berikut preferensinya, metadata, indeks pencarian, dsb.
 * File System : Berkas konfigurasi perangkat lunak, skin kustomisasi, ekstensi, gambar (termasuk di dalamnya gambar yang dihapus), dsb.

Pertimbangkan untuk membuat konfigurasi Wiki menjadi read-only saja sebelum melakukan backup - lihat. Hal ini akan memastikan data-data dalam proses backup akan konsisten.



Transfer berkas
Anda harus memilih metode untuk mentransfer berkas dari peladen letak mereka.


 * Data yang tidak pribadi bisa diterbitkan di archive.org dan/atau di direktori  peladen web Anda.
 * SCP (atau WinSCP), SFTP/FTP atau protokol transfer apa pun yang Anda mau.
 * Perusahaan hosting-nya mungkin menyediakan antarmuka manajer berkas lewat penjelajah web; periksa ke penyedia Anda.

Basis data
Mayoritas data kritikal wiki tersimpan di dalam database, berarti dapat disimpulkan bahwa umumnya proses backup akan cukup sederhana. Saat menggunakan MySQL atau MariaDB backend default, database dapat dibuang ke dalam file skrip yang nantinya dapat digunakan untuk membuat ulang database dan semua data di dalamnya dari awal. If your wiki is currently offline, its database can be backed up by simply copying the database file.

When using the default MySQL or MariaDB backend, the database can be dumped into a script file which can be used later to recreate the database and all the data in it from scratch.

Automysqlbackup
Lihat paketnya di Debian:

Pasang paketnya:

Semua basis data Anda akan disimpan di /var/lib/automysqlbackup/:

Pencadangan manual:

Mengembalikan basis data:

Untuk distribusi lainnya, lihat di Sourceforge.

Mysqldump from the command line
Contoh perkakas adalah mysqldump yang merupakan aplikasi command-line. Aplikasi ini dapat menghasilkan sebuah berkas dump dari sebuah database. Kustomisasi dapat dilakukan dengan menambahkan opsi. Misalnya kustomisasi format karakter encoding berkas keluaran.

Contoh perintah yang dapat Anda jalankan dari crontab adalah sebagai berikut:

this can be removed as soon as the dump is completed.

Example of the command to run on the Linux/UNIX shell:

mysqldump -h hostname -u userid -p --default-character-set=whatever dbname > backup.sql

Mengganti,  ,  , dan   yang sesuai. All four may be found in your (LSP) file. may be found under ; by default it is localhost. may be found under,  may be found under , where it is listed after. If  is not specified mysqldump will likely use the default of utf8, or if using an older version of MySQL, latin1. While  may be found under. After running this line from the command line mysqldump will prompt for the server password (which may be found under in LSP).

See mysqldump for a full list of command line parameters.

The output from mysqldump can instead be piped to gzip, for a smaller output file, as follows

mysqldump -h hostname -u userid -p dbname | gzip > backup.sql.gz

Some newer versions of MySQL might show an error about tablespaces and PROCESS privilege. MediaWiki does not use tablespaces. The solution is to add the --no-tablespaces option to the command:

mysqldump --no-tablespaces -h hostname -u userid -p dbname | gzip > backup.sql.gz

A similar mysqldump command can be used to produce XML output instead, by including the --xml parameter.

mysqldump -h hostname -u userid -p --xml dbname > backup.xml

and to compress the file with a pipe to gzip

mysqldump -h hostname -u userid -p --xml dbname | gzip > backup.xml.gz

Remember to also backup the file system components of the wiki that might be required, e.g., images, logo, and extensions.

Running mysqldump with Cron
Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates.

A sample command that you may run from a crontab may look like this:  nice -n 19 mysqldump -u $USER --password=$PASSWORD $DATABASE -c | nice -n 19 gzip -9 > ~/backup/wiki-$DATABASE-$(date '+%Y%m%d').sql.gz The  lowers the priority of the process.

Use valid values for,  , and. This will write a backup file with the weekday in the filename so you would have a rolling set of backups. If you want to save the files and extensions as well, you might want to use this one.

If you want to add this task in Cron through Cpanel then you must escape the character "%"

/usr/bin/mysqldump -u $USER --password=$PASSWORD $DATABASE -c | /bin/gzip > ~/backup/wiki-$DATABASE-$(date '+\%Y\%m\%d').sql.gz

or you will get an error:

/bin/sh: -c: line 0: unexpected EOF while looking for matching `'' /bin/sh: -c: line 1: syntax error: unexpected end of file

Tabel
Beberapa dari tables yang dibuang memiliki derajat temporal yang berbeda. Jadi untuk menghemat ruang disk (tidak hanya melakukan gzip), walaupun tabel tersebut perlu ada dalam dump yang baik, data mereka tidak. Namun, dalam kondisi tertentu kerugian dari harus membangun ulang semua data ini adalah dapat lebih penting daripada menghemat ruang disk (misalnya, pada wiki yang besar kecepatan restorasi menjadi penting).

Lihat arsip diskusi pada milis thread mengenai topik ini.

Latin-1 to UTF-8 conversion
See the relevant section of the upgrading page for information about this process. Also see the talk page for more information about working with character sets in general.

PostgreSQL
You can use the  tool to back up a MediaWiki PostgreSQL database. For example:

pg_dump mywiki > mywikidump.sql

will dump the  database to mywikidump.sql.

To restore the dump:

psql mywiki -f mywikidump.sql

You may also want to dump the global information, e.g. the database users:

pg_dumpall --globals > postgres_globals.sql

phpMyAdmin
Turn your wiki to read only by adding  to LocalSettings.php.

Find the wiki database in LocalSettings.php. Here is an example of what this looks like in LocalSettings.php:

  Open the browser to your phpadmin link, login, choose the wiki database.   Select Export.

Make sure all items under Export are highlighted, and make sure Structure is highlighted (it's important to maintain the table structure).

'' Optionally check Add DROP TABLE to delete existing references when importing. ''

Make sure Data is checked.   Select zipped.   Click on GO and save the backup file.   Remove  from LocalSettings.php  

Remember to also backup the file system components of the wiki that might be required, e.g. images, logo, and extensions.

HeidiSQL (alternative to phpMyAdmin)
HeidiSQL is similar to phpMyAdmin, but without any restrictions of phpMyAdmin's free version. HeidiSQL requires a direct database connection, where some hosts may only offer web interfaces (phpMyAdmin) to firewalled databases.



Sistem berkas
MediaWiki menyimpan komponen lain dari wiki di dalam sistem berkas ketika ini lebih cocok daripada memasukkan mereka ke basis data.

Berkas yang paling penting adalah $1 dan berkas yang diunggah di direktori $2 (termasuk berkas gambar, thumbnail, dan gambar matematika dan SVG yang diberikan, jika ada).


 * uploaded files in the  directory (including deleted files, thumbnails, and rendered math and SVG images, if applicable).
 * uploaded files in the  directory (including deleted files, thumbnails, and rendered math and SVG images, if applicable).

Metode yang terbaik untuk membackup berkas-berkas ini adalah dengan menempatkan mereka sebagai berkas archive seperti. Bagi pengguna sistem operasi Windows, dapat menggunakan aplikasi WinZip atau 7-zip.

Untuk varian Linux, dengan asumsi wiki disimpan di

It should be possible to backup the entire "wiki" folder in "htdocs" if using XAMPP.

Configuration files
LocalSettings.php is the most important of these, but a wiki might also have things like  or other web server configuration files that should be backed up.

Uploaded files
Files uploaded to the wiki are by default put into the  directory, separated into subdirectories such as. There are also other directories such as  and. These should all be backed up.

The  can be backed up along with everything else, but can optionally be excluded in order to save backup space. This directory stores the derived thumbnails of images and other files; generally multiple thumbnails per wiki file. After restoring from backup, these thumbnails will be recreated as required (although depending on this may need to be a manual process).



Cadangkan konten wiki (XML dump)
Merupakan ide yang bagus untuk membuat dump XML selain melakukan dump basisdata. Di dalam XML terdapat isi dari wiki (halaman wiki berikut dengan revisinya), tanpa data-yang-terkait (tidak terdapat akun user, metadata gambar, log, dsb). Dump XML independen terhadap struktur basisdata, dan dapat diimport ke versi MediaWiki yang lebih baru atau lebih lama.

XML dumps are less likely to cause problems with character encoding, as a means of transferring large amounts of content quickly, and can easily be used by third party tools, which makes XML dumps a good fallback should your main database dump become unusable.

To create an XML dump, use the command-line tool, located in the   directory of your MediaWiki installation. See for more details.

You can also create an XML dump for a specific set of pages online, using Special:Export, although attempting to dump large quantities of pages through this interface will usually time out.

To import an XML dump into a wiki, use the command-line tool. For a small set of pages, you can also use the Special:Import page via your browser (by default, this is restricted to the sysop group).

'' See for more information. ''

Without shell access to the server
If you have no shell access, use the WikiTeam Python script dumpgenerator.py from a DOS, Unix or Linux command-line. Requires Python v2. Mediawiki Client Tools are developing Mediawiki Scraper, a Python 3.x port.

User account information won't be preserved. The XML dump can include full or only most recent page history. The images dump will contain all file types with associated descriptions. The siteinfo.json and SpecialVersion.html files will contain information about wiki features such as the installed extensions and skins.

Full instructions are at the WikiTeam tutorial and Mediawiki Scraper GitHub repositories.

See also Data dumps.

Script
Script does not need to be modified for each site to be backed up. Does not (yet) rotate old backups. Usage:. Also provides a script to restore a backup. Can be used with Windows task scheduler.
 * Unofficial backup script oleh User:Duesentrieb
 * Unofficial backup script oleh Flominator; membackup semua berkas berikut basisdata dengan opsi rotasi backup.
 * User:Darizotas/MediaWiki Backup Script for Windows - a script for backing up a Windows MediaWiki install. Note: Has no restore feature.
 * WikiTeam tools - if you do not have server access (e.g. your wiki is in a free wikifarm), you can generate an XML dump and an image dump using dumpgenerator from WikiTeam tools, (Python 2). See some saved wikis.
 * Mediawiki Scraper - if you do not have server access (e.g. your wiki is in a free wikifarm), you can generate an XML dump and an image dump using dumpgenerator from Mediawiki Client Tools, (Python 3).
 * Another backup script that: dumps DB, files (just pictures by default, option to include all files in installation), and XML; puts the site into read-only mode; timestamps backups; and reads the charset from LocalSettings.
 * Another unofficial by Lanthanis that: exports the pages of specified namespaces as an XML file; dumps specified database tables; and adds further specified folders and files to a ZIP backup file.
 * Script to make periodical backups mw_backup. This script will make daily, weekly and monthly backups of your database and images directory when run as a daily cron job.

Extensions

 * – Allows users to generate and download database dumps
 * – Allows users to generate and download XML and file/image dumps

<span id="See_also">

Lihat pula

 * Help:Export is a quick and easy way to save all pages on your wiki.
 * — if you don't have a successful backup
 * — if you don't have a successful backup
 * — if you don't have a successful backup
 * — if you don't have a successful backup