「サイトバックアップ」の版間の差分

提供:MoodleDocs
移動先:案内検索
編集の要約なし
71行目: 71行目:
If you have not customised the code, you can always download a new copy. However, it is still a good idea to keep your own local copy with the rest of your backup, and if you are doing customisation, it is essential. The steps are the same as for backing up the data files.
If you have not customised the code, you can always download a new copy. However, it is still a good idea to keep your own local copy with the rest of your backup, and if you are doing customisation, it is essential. The steps are the same as for backing up the data files.


= Restoring a site backup =
= サイトバックアップのリストア =


If you have followed the above instructions and created a backup of a Moodle site, you may need to know how to restore the site backup you created.  Here is a set of basic steps that make up the restore process.
If you have followed the above instructions and created a backup of a Moodle site, you may need to know how to restore the site backup you created.  Here is a set of basic steps that make up the restore process.

2009年8月9日 (日) 00:29時点における版

作成中です - Mitsuhiro Yoshida 2009年8月7日 (金) 18:03 (UTC)

最良の信頼性および短時間の復旧時間のため、すべてのデータを保存する、サイトバックアップをお勧めします。

何をバックアップすべきですか?

A Moodle system comprises three parts:

  1. the data stored in the database,
  2. the uploaded, and other data files, stored on disc, and
  3. the files containing the Moodle code

You can confirm where all these things are for your Moodle installation by checking your config.php file. There are several parameters that tell Moodle which database to connect to:

  1. $CFG->dataroot controls where the data files are stored; and
  2. $CFG->dirroot points to where the code is stored.

あなたのMoodleサイトのバックアップを作成する

データベース

There are two main things you need to make a copy of - the database and the uploaded files. The Moodle scripts themselves are less important, since you can always download a fresh copy if you have to.

There are many ways to do such backups. Here is an outline of a little script you can run on Unix to backup the database (it works well to have such a script run daily via a cron task):

cd /my/backup/directory
mv moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h example.com -u myusername --password=mypassword -C -Q -e --create-options mydatabasename > moodle-database.sql
gzip moodle-database.sql

文字コード

When dumping the entire Moodle database, administrators should be careful to watch for possible character encoding issues. In some instances, backups created with mysqldump or phpMyAdmin may not properly encode all of the data resulting in spurious A characters. One solution is to use MySQL Administrator 1.1 or another tool that will force a UTF-8 dump of the data.

データベースバックアップ用ツール

  • phpMyAdmin is the tool of choice with most web hosting providers.
  • MySQLDumper is a backup script for MySQL databases, written in PHP and Perl. MySQLDumper uses a proprietary technique to avoid execution interruption when running PHP scripts (the max. execution time is usually set to 30 seconds). MySQLDumper also cares for the encoding problems mentioned above. It also works with compressed files.

データファイル

For the files, you can use rsync regularly to copy only the changed files to another host:

rsync -auvtz --delete -e ssh mysshusername@example.com:/my/server/directory /my/backup/directory/

If you want to run the cronscript at the machine you are running Moodle at you have to use following rsync syntax

rsync -auvtz --delete -e ssh /path/to/local/folder/ remoteuser@remoteserver:/path/to/remote/folder/

If you do not want the root mailbox be spammed by statusmails of the rsync use:

 rsync -autzq --delete -e ssh /path/to/local/folder/ remoteuser@remoteserver:/path/to/remote/folder/

If your Moodle hosting provider does not allow ssh (or just do not provide it) and you have simple ftp access with a username and a password you can also use:

mkdir /tmp/remote-folder
curlftpfs ftp://username:password@ftp.your-site.com /tmp/remote-folder
rsync -auvtz --delete /tmp/remote-folder /my/local/backup/folder/
umount /tmp/remote-folder
rmdir /tmp/remote-folder

Entire database backup can be accomplished (tested on cPanel web interface) using the following command:

wget --http-user=username --http-password=password http://your-site.com:2082/getsqlbackup/moodle.sql.gz

and the entire backup of the Moodle code tree:

wget --http-user=username --http-password=password http://your-site.com:2082/getbackup/backup-your-site.com-`date +"%-m-%d-%Y"`.tar.gz

Some customization might be needed for other web interface like (webmin?)

コードファイル

If you have not customised the code, you can always download a new copy. However, it is still a good idea to keep your own local copy with the rest of your backup, and if you are doing customisation, it is essential. The steps are the same as for backing up the data files.

サイトバックアップのリストア

If you have followed the above instructions and created a backup of a Moodle site, you may need to know how to restore the site backup you created. Here is a set of basic steps that make up the restore process.

1. Rename the original Moodle directory to something different (so you still have it) and copy the backed up Moodle directory or a newly downloaded Moodle directory in its place.

2. If you are running MySQL, a backup of the database should be a .sql, .gz or .tar.gz file. If it is .tar.gz or .gz you need to extract it until it is an sql file.

tar -xzvf moodlesqlfile.tar.gz

3. If you are running mysql, import the SQL file back into a newly created database on the MySQL server. Be careful here, some backups try to import right back into the same working database that Moodle is connected to. This causes database problems that damage a Moodle installation. The best thing to do is make a new database, restore the backed up database into it, and change the Moodle config.php file to connect to this new database (this way you still have the original database).

Once you have created the new database:

mysql -p new_database < moodlesqlfile.sql

関連情報