Moodle: Copy Database

From OnnoWiki
Jump to navigation Jump to search

A Moodle system comprises three parts:

  1. The data stored in the database (For example, a MySQL database)
  2. The uploaded files (For example, site and course files uploaded via Moodle located in moodledata)
  3. The Moodle code (For example, everything in server/htdocs/moodle)

You can confirm where all these things are located in a Moodle installation by checking the config.php file.

  1. $CFG->dbname shows the database name
  2. $CFG->prefix shows the the database table name prefix
  3. $CFG->dataroot controls where the uploaded files are stored; and
  4. $CFG->wwwroot points to where the code is stored.

Tip

Generally speaking, the database ("dbname and prefix") and the uploaded files (dataroot) are the two most important to copy on a regular basis. These contain information that will change most often.

The Moodle code (wwwroot) is less important as a frequent backup, since it will only change when the the actual code is changed through upgrades, addins and code tweaks. You can always get a copy of the standard Moodle code from http://download.moodle.org so you only have to backup the parts you added or changed yourself.


pakai mysqldump

WARNING: Entah kenapa password user jadi beda / berubah, kayanya karena hash

  • Install Moodle Kosong di mesin mirror
  • di mesin asal
/usr/bin/mysqldump -u root -p123456 moodle -c | /bin/gzip -9 > moodle.sql.gz
scp moodle.sql.gz stkip@10.150.5.249:
  • di mesin mirror
cd ~
gunzip moodle.sql.gz 
sudo mysqladmin --user=root --password=123456 --force drop moodle
sudo mysqladmin --user=root --password=123456 create moodle
sudo mysql -u moodle -pmoodle moodle < ~/moodle.sql

scp database

WARNING: Cara ini akan menimbulkan error karena banyak yang kurang lengkap

mysql -u root -p123456
create database moodle;
ALTER DATABASE moodle charset=utf8;
grant ALL on root.* to moodle@localhost;
grant ALL on moodle.* to moodle@localhost identified by "moodle";
grant ALL on moodle.* to moodle identified by "moodle";
exit


scp -r root@10.150.5.250:/var/lib/mysql/moodle /var/lib/mysql
scp -r root@10.150.5.250:/var/moodledata /var
scp -r root@10.150.5.250:/var/www/moodle /var/www
chmod -Rf 777 /var/moodledata/lang/
chown -Rf www-data.www-data /var/moodledata/lang/
chown -Rf www-data.www-data /var/moodledata/
chmod -Rf 777 /var/www/moodle	
chown -Rf www-data.www-data /var/www/moodle 
chown -Rf mysql.mysql /var/lib/mysql/moodle
config.php:$CFG->wwwroot   = 'http://10.150.5.250/moodle';
vi /var/www/moodle/config.php

Referensi

Pranala Menarik