Difference between revisions of "Moodle: Copy Database"
Onnowpurbo (talk | contribs)  | 
				Onnowpurbo (talk | contribs)   | 
				||
| (3 intermediate revisions by the same user not shown) | |||
| Line 24: | Line 24: | ||
  http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php  |   http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php  | ||
  http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=co  |   http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=co  | ||
| + |  http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=log  | ||
* siapkan  | * siapkan  | ||
| Line 70: | Line 71: | ||
| + | Menjalankan script  | ||
| − | + |  php moodle_backup.php  | |
==menggunakan mysqldump==  | ==menggunakan mysqldump==  | ||
| Line 79: | Line 81: | ||
* di mesin asal  | * di mesin asal  | ||
| − |   /usr/bin/mysqldump -u root -p123456 moodle   | + |   /usr/bin/mysqldump -u root -p123456 -C -Q -e --create-options moodle | /bin/gzip -9 > moodle-database.sql.gz  | 
| − |   scp moodle.sql.gz stkip@10.150.5.249:  | + |   scp moodle-database.sql.gz stkip@10.150.5.249:  | 
| + | |||
* di mesin mirror  | * di mesin mirror  | ||
  cd ~  |   cd ~  | ||
| − |   gunzip moodle.sql.gz    | + |   gunzip moodle-database.sql.gz    | 
  sudo mysqladmin --user=root --password=123456 --force drop moodle  |   sudo mysqladmin --user=root --password=123456 --force drop moodle  | ||
  sudo mysqladmin --user=root --password=123456 create moodle  |   sudo mysqladmin --user=root --password=123456 create moodle  | ||
| − |   sudo mysql -u moodle -pmoodle moodle < ~/moodle.sql  | + |   sudo mysql -u moodle -pmoodle moodle < ~/moodle-database.sql  | 
| + |  scp -r root@10.150.5.250:/var/moodledata /var  | ||
| + |  sudo chmod -Rf 777 /var/moodledata/lang/  | ||
| + |  sudo chown -Rf www-data.www-data /var/moodledata/lang/  | ||
| + |  sudo chown -Rf www-data.www-data /var/moodledata/  | ||
==scp database==  | ==scp database==  | ||
Latest revision as of 16:04, 19 March 2012
A Moodle system comprises three parts:
- The data stored in the database (For example, a MySQL database)
 - The uploaded files (For example, site and course files uploaded via Moodle located in moodledata)
 - 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.
- $CFG->dbname shows the database name
 - $CFG->prefix shows the the database table name prefix
 - $CFG->dataroot controls where the uploaded files are stored; and
 - $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.
menggunakan moodle_backup.php
- Download dari
 
http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=co http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=log
- siapkan
 
apt-get install zip mkdir /var/moodlebackups chmod -Rf 777 /var/moodlebackups chown -Rf nobody.nogroup /var/moodlebackups
- buat script
 
cd /usr/local/bin touch moodle_backup.php chmod -Rf 777 moodle_backup.php chown -Rf nobody.nogroup moodle_backup.php vi moodle_backup.php
Ubah agar
//================================= // CONFIG SECTION - EDIT ME //================================= // location of Moodle config files // list one or more config file locations on your system // whatever user this runs as needs read permission to the config files // AND to the moodledata area $configs = array(); $configs[] = '/var/www/moodle/config.php'; //$configs[] = '/var/www/moodle2/config.php'; //$configs[] = '/var/www/moodle2/config.php'; //$configs[] = '/var/www/moodle2/config.php'; // path to your zip binary // if you're not sure, do 'which zip' on the command line $zippath = '/usr/bin/zip'; // location of backup folder // do not include trailing slash // whatever user this runs as needs write permissions to this $backuploc = '/var/moodlebackups'; //================================= // END OF CONFIG SECTION //=================================
Menjalankan script
php moodle_backup.php
menggunakan 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 -C -Q -e --create-options moodle | /bin/gzip -9 > moodle-database.sql.gz scp moodle-database.sql.gz stkip@10.150.5.249:
- di mesin mirror
 
cd ~ gunzip moodle-database.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-database.sql scp -r root@10.150.5.250:/var/moodledata /var sudo chmod -Rf 777 /var/moodledata/lang/ sudo chown -Rf www-data.www-data /var/moodledata/lang/ sudo chown -Rf www-data.www-data /var/moodledata/
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
- http://www.edugeek.net/forums/virtual-learning-platforms/37174-moodle-linux-backup-script.html
 - http://docs.moodle.org/22/en/Site_restore
 - http://docs.moodle.org/22/en/Site_backup
 - http://cvs.moodle.org/contrib/tools/moodle_backup/moodle_backup.php?view=log&pathrev=MOODLE_22_STABLE
 
Pranala Menarik
- Moodle
 - Instalasi Moodle
 - Moodle: Mengubah Hostname atau wwwroot
 - Moodle: Konfigurasi CMS
 - Moodle: Administrasi User
 - SchoolOnffLine: Moodle Upload User
 - Moodle: Administrasi Kuliah
 - Moodle: Install Dragmath
 - Moodle: Penggunaan Dragmath
 - Moodle: Aktifasi Latex
 - Moodle: Authentikasi LDAP
 - Moodle: Copy Database
 - Linux Howto