Difference between revisions of "Setup MediaWiki on AWS"
(→Crontab) |
|||
Line 127: | Line 127: | ||
0 4 * * * env HOME=/home/ubuntu duply test backup | 0 4 * * * env HOME=/home/ubuntu duply test backup | ||
</source> | </source> | ||
+ | =Backup Scripts= | ||
+ | <onlydft> | ||
+ | ==On Xgridmac2== | ||
+ | ::<source lang="bash"> | ||
+ | #! /bin/bash | ||
+ | |||
+ | |||
+ | # ------------------------------------------------------------------------- | ||
+ | # copy MySQL from cirrus to xgridmac2 | ||
+ | # ------------------------------------------------------------------------- | ||
+ | # backup dftwiki3 database to local zipped sql file on cirrus | ||
+ | cd ~/dftwiki3 | ||
+ | ssh -t dthiebaut@www.science.smith.edu '( mysqldump -u thiebaut -pdft45tfd dftwiki3 )' > dftwiki3.sql 2> /dev/null | ||
+ | gzip -f dftwiki3.sql | ||
+ | |||
+ | # ------------------------------------------------------------------------- | ||
+ | # copy wiki directory tree on cirrus (only important files) to xgridmac2 | ||
+ | # ------------------------------------------------------------------------- | ||
+ | # create zipped tar of dftwiki images and media | ||
+ | #ssh -t dthiebaut@www.science.smith.edu '( cd /var/www/departments/cs/dftwiki ; tar -czf /Users/dthiebaut/temp/dftwiki.tgz images media skins 2> /dev/null )' 2> /dev/null | ||
+ | #rsync -az -e ssh dthiebaut@www.science.smith.edu:temp/dftwiki3.tgz dftwiki.tgz 2> /dev/null | ||
+ | |||
+ | rsync -az -e ssh dthiebaut@www.science.smith.edu:/var/www/departments/cs/dftwiki/images . 2> /dev/null | ||
+ | rsync -az -e ssh dthiebaut@www.science.smith.edu:/var/www/departments/cs/dftwiki/media . 2> /dev/null | ||
+ | rsync -az -e ssh dthiebaut@www.science.smith.edu:/var/www/departments/cs/dftwiki/skins . 2> /dev/null | ||
+ | |||
+ | # ------------------------------------------------------------------------- | ||
+ | # copy dftwiki3.sql from xgridmac2 to MySQL dftwiki3 database on | ||
+ | # EC2 instance | ||
+ | # ------------------------------------------------------------------------- | ||
+ | gunzip -c dftwiki3.sql.gz |ssh -t ubuntu@dominiquefthiebaut.com "cat - | mysql -u thiebaut -pdft45tfd dftwiki3 " 2> /dev/null | ||
+ | |||
+ | # ------------------------------------------------------------------------- | ||
+ | # rsync skins images and media directories from ~/dftwiki3/ to EC2 | ||
+ | # in /data/html/dftwiki3/ | ||
+ | # ------------------------------------------------------------------------- | ||
+ | cd ~/dftwiki3/ | ||
+ | for dir in images/ skins/ media/ ; do | ||
+ | fullDir=/data/html/dftwiki3/$dir | ||
+ | rsync -az -e ssh --rsync-path="sudo rsync" $dir ubuntu@dominiquefthiebaut.com:$fullDir | ||
+ | ssh -t ubuntu@dominiquefthiebaut.com sudo chown -R www-data:www-data $fullDir 2> /dev/null | ||
+ | |||
+ | done | ||
+ | |||
+ | </source> | ||
+ | |||
+ | </onlydft> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | [[Category:AWS]][[Category:Mediawiki]][[Category:EC2]][[Category:S3]] |
Revision as of 20:56, 15 January 2018
D. Thiebaut (talk) 16:44, 13 January 2018 (EST)
This page contains very sketchy steps for setting up (in my case moving) an existing mediawiki installation to AWS. This list is mostly for myself to remember what steps I have taken. |
Contents
Mediawiki Installation/Upgrade
- Follow the steps from https://www.mediawiki.org/wiki/Manual:Upgrading
- Download the new mediawiki in a directory belonging to the Web server
- unzip/untar.
- Create new MySql user/password/database on localhost (same host as Web server)
- Verify that base directory of mediawiki installation is accessible from a browser by putting a phpinfo.php file in it and loading it up with browser.
- use browser and point to /mw-config in the mediawiki web directory. Enter database information.
- Update the LocalSettings.php file
- If migrating, copy the extensions, skins, images, media, Downloads directory from old wiki to new installed wiki.
- Install one extension at a time in extensions directory, and at the end of LocalSettings.php
Updated Extensions
I had to update several extensions to match the new format.
AWS
EC2
- Go for free-tier t2-micro with attached EBS drive (20GB)
- Set OS to Ubuntu Server 16.04.
-
...
- Install MediaWiki on it, without data
- Install emacs
- Make an AMI out of it
- Move the images, extensions, skins, etc to newly installed MW.
- Install ddclient.
...
S3
- Create a bucket for backups
...
Backups
- Install duplicity and duply
- In the process create a GnuPG key for encryption of backups on S3
duply test create
- creates a profile to backup for MediaWiki in /data/html/dftwiki3
- All information in /home/ubuntu/.duply/test/conf
- Duplicity conf file:
- create script in /usr/local/bin, called backupDftWiki3MySql.sh to do mysqldump of MW to an sql file, and store it:
#! /bin/bash
# This will be called from a root cron job
mysqldump --user=thiebaut --password=xxxxxxxxxx dftwiki3 > /data/html/dftwiki3/backups/dftwiki3.sql 2> /dev/null
cd /data/html/dftwiki3/backups
gzip -f dftwiki3.sql
Route 53
- Created new domain dominiquefthiebaut.com
- Create record to map it to EC2 instance.
- Find public IP of EC2
...
and put in edit-box in record. Accept defaults.
- Disable ddclient on EC2 and with dyndns.
- Change the name of the host in /etc/hosts from hadoop02 to new hostname.
Crontab
- Crontab runs as root
# ------------------------------------------------ # use mysqldump to dump mysql database for dftwiki3 # into a file called dftwiki3.sql in /data/html/dftwiki/backups 0 3 * * * /usr/local/bin/backupDftWiki3MySql.sh # ------------------------------------------------ # use duplicity (via duply) to backup /data/html/dftwiki3's main # directories to aws s3. The configuration and information about # which S3 bucket is in ~ubuntu/.duply/test/conf 0 4 * * * env HOME=/home/ubuntu duply test backup
Backup Scripts