Difference between revisions of "Moodle: Backup Site"

From OnnoWiki
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
  
Script
+
Script untuk backup sebuah situs moodle
  
 +
cd /var/www/pustaka/backupmoodle
 
  mv moodle-database.sql.gz moodle-database-old.sql.gz
 
  mv moodle-database.sql.gz moodle-database-old.sql.gz
 
  mysqldump -h namamesin -u usernamemoodle --password=passwordmoodle -C -Q -e --create-options databasemoodle > moodle-database.sql
 
  mysqldump -h namamesin -u usernamemoodle --password=passwordmoodle -C -Q -e --create-options databasemoodle > moodle-database.sql
Line 11: Line 12:
 
  chmod -Rf 777 /var/www/pustaka/backupmoodle
 
  chmod -Rf 777 /var/www/pustaka/backupmoodle
 
  chown -Rf nobody.nogroup /var/www/pustaka/backupmoodle
 
  chown -Rf nobody.nogroup /var/www/pustaka/backupmoodle
 +
 +
 +
Script Backup Internet OFFLINE
 +
 +
mkdir -p /var/www/html/pustaka/backupmoodle
 +
cd /var/www/html/pustaka/backupmoodle
 +
mv moodle-database.sql.gz moodle-database-old.sql.gz
 +
mysqldump -h localhost -u moodle --password=moodle -C -Q -e --create-options moodle > moodle-database.sql
 +
gzip moodle-database.sql
 +
tar czf /var/www/html/pustaka/backupmoodle/moodlecms.tar.gz /var/www/html/moodle
 +
tar czf /var/www/html/pustaka/backupmoodle/moodledata.tar.gz /var/moodledata/
 +
chmod -Rf 777 /var/www/html/pustaka/backupmoodle
 +
chown -Rf nobody.nogroup /var/www/html/pustaka/backupmoodle
 +
 +
  
  
Line 26: Line 42:
  
 
  mysql -u root -ppassword databasemoodleyangbaru < moodle-database.sql
 
  mysql -u root -ppassword databasemoodleyangbaru < moodle-database.sql
 +
 +
* Copy /var/moodledata dari situs lama ke yang baru.
  
 
==Download Data dari Cyberlearning.web.id==
 
==Download Data dari Cyberlearning.web.id==
Line 34: Line 52:
 
  wget http://cyberlearning.web.id/pustaka/backupmoodle/moodle-database.sql.gz -O /var/www/html/pustaka/backupmoodle/moodle-database.sql.gz
 
  wget http://cyberlearning.web.id/pustaka/backupmoodle/moodle-database.sql.gz -O /var/www/html/pustaka/backupmoodle/moodle-database.sql.gz
 
  wget http://cyberlearning.web.id/pustaka/backupmoodle/moodlecms.tar.gz -O /var/www/html/pustaka/backupmoodle/moodlecms.tar.gz
 
  wget http://cyberlearning.web.id/pustaka/backupmoodle/moodlecms.tar.gz -O /var/www/html/pustaka/backupmoodle/moodlecms.tar.gz
 +
wget http://cyberlearning.web.id/pustaka/backupmoodle/moodledata.tar.gz -O /var/www/html/pustaka/backupmoodle/moodledata.tar.gz
 
  chmod -Rf 777 /var/www/html/pustaka/backup*
 
  chmod -Rf 777 /var/www/html/pustaka/backup*
 
  chown -Rf nobody.nogroup /var/www/html/pustaka/backup*
 
  chown -Rf nobody.nogroup /var/www/html/pustaka/backup*
Line 45: Line 64:
 
  /var/www/html/moodle/
 
  /var/www/html/moodle/
 
  /var/www/html/pustaka/backupmoodle/
 
  /var/www/html/pustaka/backupmoodle/
 +
 +
* Asumsi database
 +
 +
username root
 +
password 123456
 +
database moodle
  
 
Restore
 
Restore
Line 58: Line 83:
 
  cp /tmp/config.php /var/www/html/moodle
 
  cp /tmp/config.php /var/www/html/moodle
 
  chown -Rf www-data.www-data /var/www/html/moodle
 
  chown -Rf www-data.www-data /var/www/html/moodle
 +
chown -Rf www-data.www-data /var/moodledata &
 
  cd /var/www/html/pustaka/backupmoodle
 
  cd /var/www/html/pustaka/backupmoodle
 
  gunzip moodle-database.sql.gz
 
  gunzip moodle-database.sql.gz
  mysqladmin --user=root --password=123456 --force drop moodleOC
+
  mysqladmin --user=root --password=123456 --force drop moodle
  mysqladmin --user=root --password=123456 create moodleOC
+
  mysqladmin --user=root --password=123456 create moodle
  mysql -u root -p123456 moodleOC < /var/www/html/pustaka/backupmoodle/moodle-database.sql
+
  mysql -u root -p123456 moodle < /var/www/html/pustaka/backupmoodle/moodle-database.sql
 
  service mysql stop
 
  service mysql stop
 
  service mysql start
 
  service mysql start

Latest revision as of 04:27, 1 September 2024

Sumber: https://docs.moodle.org/23/en/Site_backup


Script untuk backup sebuah situs moodle

cd /var/www/pustaka/backupmoodle
mv moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h namamesin -u usernamemoodle --password=passwordmoodle -C -Q -e --create-options databasemoodle > moodle-database.sql
gzip moodle-database.sql
tar czf /var/www/pustaka/backupmoodle/moodlecms.tar.gz /var/www/moodle
tar czf /var/www/pustaka/backupmoodle/moodledata.tar.gz /var/moodledata/
chmod -Rf 777 /var/www/pustaka/backupmoodle
chown -Rf nobody.nogroup /var/www/pustaka/backupmoodle


Script Backup Internet OFFLINE

mkdir -p /var/www/html/pustaka/backupmoodle
cd /var/www/html/pustaka/backupmoodle
mv moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h localhost -u moodle --password=moodle -C -Q -e --create-options moodle > moodle-database.sql
gzip moodle-database.sql
tar czf /var/www/html/pustaka/backupmoodle/moodlecms.tar.gz /var/www/html/moodle
tar czf /var/www/html/pustaka/backupmoodle/moodledata.tar.gz /var/moodledata/
chmod -Rf 777 /var/www/html/pustaka/backupmoodle
chown -Rf nobody.nogroup /var/www/html/pustaka/backupmoodle



Restore

  • Buat site moodle seperti biasa
  • Selamatkan file config.php, misalkan ke /tmp/config.php atau ~/config.php
  • Setup database
  • Restore, misalnya,
mysql -p new_database < moodlesqlfile.sql

atau

mysql -u root -ppassword databasemoodleyangbaru < moodle-database.sql
  • Copy /var/moodledata dari situs lama ke yang baru.

Download Data dari Cyberlearning.web.id

Contoh script untuk men-download dari cyberlearning.web.id

wget http://cyberlearning.web.id/pustaka/backupmoodle/moodle-database-old.sql.gz -O /var/www/html/pustaka/backupmoodle/moodle-database-old.sql.gz
wget http://cyberlearning.web.id/pustaka/backupmoodle/moodle-database.sql.gz -O /var/www/html/pustaka/backupmoodle/moodle-database.sql.gz
wget http://cyberlearning.web.id/pustaka/backupmoodle/moodlecms.tar.gz -O /var/www/html/pustaka/backupmoodle/moodlecms.tar.gz
wget http://cyberlearning.web.id/pustaka/backupmoodle/moodledata.tar.gz -O /var/www/html/pustaka/backupmoodle/moodledata.tar.gz
chmod -Rf 777 /var/www/html/pustaka/backup*
chown -Rf nobody.nogroup /var/www/html/pustaka/backup*

Restore Cyberlearning

  • Pastikan anda sudah menginstalasi moodle kosong.
  • Selamatkan config.php ke /tmp/config.php atau ~/config.php
  • Misalkan lokasi moodle dan backup-nya adalah
/var/www/html/moodle/
/var/www/html/pustaka/backupmoodle/
  • Asumsi database
username root
password 123456
database moodle

Restore

cd /var/www/html/pustaka/backupmoodle/
rm -Rf /var/www/html/moodle
rm -Rf /var/moodledata
tar zxvf moodlecms.tar.gz
mv /var/www/html/pustaka/backupmoodle/var/www/moodle/ /var/www/html/
tar zxvf moodledata.tar.gz
mv /var/www/html/pustaka/backupmoodle/var/moodledata /var
rm -Rf /var/www/html/pustaka/backupmoodle/var/
cp /tmp/config.php /var/www/html/moodle
chown -Rf www-data.www-data /var/www/html/moodle
chown -Rf www-data.www-data /var/moodledata &
cd /var/www/html/pustaka/backupmoodle
gunzip moodle-database.sql.gz
mysqladmin --user=root --password=123456 --force drop moodle
mysqladmin --user=root --password=123456 create moodle
mysql -u root -p123456 moodle < /var/www/html/pustaka/backupmoodle/moodle-database.sql
service mysql stop
service mysql start

Referensi