MediaWiki's Installation, Backup, Restore, and Recovery
MediaWiki Installation
Docker
Docker pull
docker pull bitnami/mariadb:latest
docker pull bitnami/mediawiki:latest
Docker-compose
curl -sSL https://raw.githubusercontent.com/benkoo/TensorCloud/master/mariadb.yml > mariadb.yml
curl -sSL https://raw.githubusercontent.com/benkoo/TensorCloud/master/mediawiki.yml > mediawiki.yml
docker-compose -f bitnami/mariadb:latest -f bitnami/mediawiki:latest up -d
MediaWiki Data Backup
The most essential command is the following:
First, create a temporary working directory:
mkdir /tmp/workingBackupMediaFiles
It is common to have files not being dumped out, due to errors caused by escape characters in File names. This will be resolved in the future.
You must first go to the proper directory, in the case of standard PKC configuration, you must make sure you launch the following command at this location /var/www/html
:
php maintenance/dumpUploads.php \
| sed 's~mwstore://local-backend/local-public~./images~' \
| xargs cp -t /tmp/MediaFiles
Then, compress the file in a zip directory.
zip -r ~/Mediafiles.zip /tmp/MediaFiles
Remember to remove the temporary files and its directory.
rm -r /tmp/workingBackupMediaFiles
For more information:
Reference the following Stack Overflow answer:
- Exporting and importing images in MediaWiki
- MediaWiki data backup
- MediaWiki Backup and Restore Bash Scripts
Docker exec
docker ps & docker exec -it YourMariadbContainerID bash
MysqlDump
mysql -u wiki -p -S /opt/lampp/var/mysql/mysql.sock //with defined socks.
And show progress:
mysqldump -S /opt/lampp/var/mysql/mysql.sock -h [domain name/ip] -u [username] -p[password] [databasename] | pv --progress --size 4096m > [filename.sql]
And gzip:
mysqldump -S /opt/lampp/var/mysql/mysql.sock -h [domain name/ip] -u [username] -p[password] [databasename] | pv --progress --size 4096m | gzip > [filename.sql.gz]
Jenkins
http://toyhouse.cc:8080/job/mediawiki_backup/
http://toyhouse.cc:8080/job/mediawiki_restore/
Rancher snapshot
convoy snapshot create (volume name or UUID) --name (snapshot name)
Volumerize
Docker Volume Backups Multiple Backends,more:https://github.com/blacklabelops/volumerize
0.wget mariadb_mediawiki.yml
curl -sSL https://raw.githubusercontent.com/benkoo/TensorCloud/master/mariadb_mediawiki.yml > mariadb_mediawiki.yml
1.start mariadb_mediawiki
docker-compose -f mariadb_mediawiki.yml up -d
2.0 run volumerize backup
docker run -d \ --name volumerize \ -v mediawiki_data:/source/application_data:ro \ -v mariadb_data:/source/application_database_data:ro \ -v mediawiki_data:/source/application_configuration:ro \ -v backup_volume:/backup \ -v cache_volume:/volumerize-cache \ -e "VOLUMERIZE_SOURCE=/source" \ -e "VOLUMERIZE_TARGET=file:///backup" \ blacklabelops/volumerize
2.1 exec volumerize backup
docker exec volumerize backup
3.1 stop volumerize
docker stop $(docker ps -a -q)
3.1.1 Remove volumerize
docker rm volumerize
3.2 stop volumerize
docker stop volumerize
4.volumerize restore
docker run -d \ --name volumerize \ -v mediawiki_data:/source/application_data:ro \ -v mariadb_data:/source/application_database_data:ro \ -v mediawiki_data:/source/application_configuration:ro \ -v backup_volume:/backup:ro \ -v cache_volume:/volumerize-cache \ -e "VOLUMERIZE_SOURCE=/source" \ -e "VOLUMERIZE_TARGET=file:///backup" \ blacklabelops/volumerize
5.start mariadb_mediawiki again to verify
docker-compose -f mariadb_mediawiki.yml up -d
6.start volumerize again
docker start volumerize
MediaWiki Data Recovery
- MediaWiki restore
- Exporting and Importing Images in MediaWiki (on http://stackoverflow.com)
- MediaWiki官方网站上的全网备份与恢复介绍 (Full site restore)
MySQL import
docker ps & docker exec -it YourMariadbContainerID bash
mysql -h <host.name> -u <username> -p<PlainPassword> <databasename> < <filename.sql>
LocalSettings.php
vim /bitnami/mediawiki/LocalSettings.php
$wgDBprefix = "wiki_";//your wiki prefix;
Rancher backup
convoy backup create (snapshot name or UUID) --dest s3://(bucket_name@region_name)/
- convoy-a-docker-volume-driver-for-backup-and-recovery-of-persistent-data
- S3 for ToyhouseRancher
- Convoy Quick Start Guide
MediaWiki Jenkins
curl -sSL https://raw.githubusercontent.com/benkoo/TensorCloud/master/jenkins.yml > jenkins.yml
docker-compose -f jenkins.yml up -d