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

提供:MoodleDocs
移動先:案内検索
(ページの作成: 作成中です - ~~~~ Site backups are recommended in order to have all data saved with the best confidence and the shortest recovery time. = What needs to be backed up? = A ...)
 
(Done!)
 
(同じ利用者による、間の23版が非表示)
1行目: 1行目:
作成中です - [[利用者:Mitsuhiro Yoshida|Mitsuhiro Yoshida]] 2009年8月7日 (金) 18:03 (UTC)
最良の信頼性および復旧時間を短くするため、すべてのデータを保存するサイトバックアップをお勧めします。


Site backups are recommended in order to have all data saved with the best confidence and the shortest recovery time.
= 何をバックアップすべきですか? =


= What needs to be backed up? =
Moodleシステムは、下記3つの部分から成ります:
# データが保存されている'''データベース'''、
# ディスクに保存された、アップロードおよびその他の'''データファイル'''、
# '''Moodleコード'''を含むファイル


A Moodle system comprises three parts:
あなたのMoodleに関して、これらすべてのデータがどこにあるのか、'''config.php'''により確認することができます。どのデータベースおよびデータを使用すべきか、Moodleに伝えるため、いくつかのパラーメータがあります:
# the data stored in the '''database''',
# '''$CFG->dataroot''' では、データファイルをどこに保存するか、コントロールします。そして、
# the uploaded, and other '''data files''', stored on disc, and
# '''$CFG->dirroot''' では、Moodleコードが保存される場所を示します。
# 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:
= あなたのMoodleサイトのバックアップを作成する =
# '''$CFG->dataroot''' controls where the ''data files'' are stored; and
# '''$CFG->dirroot''' points to where the ''code'' is stored.


= Creating a backup of your Moodle site =
== データベース ==


== Database ==
あなたがMoodleをバックアップするには、2つの中心的なデータがあります - データベースおよびアップロードファイルです。あなたが必要な場合、いつでも最新のデータをダウンロードできるため、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.
バックアップには、数多くの方法があります。以下、あなたがUnixでデータベースをバックアップするための、小さなスクリプトの概略です (cronタスクを使って、日々動作させるスクリプトとして有用です):
 
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
  cd /my/backup/directory
27行目: 25行目:
  gzip moodle-database.sql
  gzip moodle-database.sql


=== Character encoding ===
=== 文字コード ===


When dumping the entire Moodle database, administrators should be careful to watch for possible character encoding issues. In some instances, backups created with [http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html mysqldump] or [http://www.phpmyadmin.net 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.
Moodleデータベースすべてをダンプする場合、管理者は起こり得る文字コード問題に関して、慎重になるべきです。場合によっては、[http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html mysqldump]または[http://www.phpmyadmin.net phpMyAdmin]によって作成されるバックアップは、すべてのデータを適切にエンコードできず、結果として文字化けが発生してしまいます。1つの解決方法は、MySQL Administrator 1.1または、データのUTF-8ダンプを強制する、別のツールを使用することです。


=== Tools for database backups ===
=== データベースバックアップ用ツール ===


* [http://www.phpmyadmin.net phpMyAdmin] is the tool of choice with most web hosting providers.
* [http://www.phpmyadmin.net phpMyAdmin] 多くのウェブホスティングプロバイダが選択するツールです。
* [http://www.mysqldumper.de/en/ 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.
* [http://www.mysqldumper.de/en/ MySQLDumper] MySQLデータベース用バックアップスクリプトです。PHPおよびPerlで書かれています。MySQLDumperでは、PHPスクリプト実行時の中断 (通常、最大実行時間は30秒です) を避けるための独自技術を使用しています。MySQLDumperは、上記で指摘された文字コード問題にも対応しています。また、圧縮ファイルでも動作します。


== Data files ==
== データファイル ==


For the files, you can use '''rsync''' regularly to copy only the changed files to another host:
ファイルに関して、変更されたファイルのみ別のホストにコピーするため、あなたは定期的に'''rsync'''コマンドを使用することができます:


  rsync -auvtz --delete -e ssh mysshusername@example.com:/my/server/directory /my/backup/directory/
  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
あなたが、Moodleを動作させているマシンでcronスクリプトを実行させたい場合、次のrsync構文を使用してください:


  rsync -auvtz --delete -e ssh /path/to/local/folder/ remoteuser@remoteserver:/path/to/remote/folder/
  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のステータスメールでrootメールボックスを一杯にしたくない場合、次のrsync構文を使用してください:
   
   
   rsync -autzq --delete -e ssh /path/to/local/folder/ remoteuser@remoteserver:/path/to/remote/folder/
   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
あなたのMoodleホスティングプロバイダがsshを許可しない場合 (または、単に提供していない場合)、そしてあなたがユーザ名およびパスワードを使ってFTPアクセスできる場合、次のコマンドも使用できます:
you can also use:


  mkdir /tmp/remote-folder
  mkdir /tmp/remote-folder
59行目: 56行目:
  rmdir /tmp/remote-folder
  rmdir /tmp/remote-folder


Entire database backup can be accomplished (tested on cPanel web interface) using the following command:
データベースすべてのバックアップは、次のコマンドで実行できます (cPanelウェブインターフェースでテスト済み):


  wget --http-user=username --http-password=password http://your-site.com:2082/getsqlbackup/moodle.sql.gz
  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:
そして、Moodleコードツリーすべてのバックアップは、次のコマンドで実行できます:
  wget --http-user=username --http-password=password http://your-site.com:2082/getbackup/backup-your-site.com-`date +"%-m-%d-%Y"`.tar.gz
  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?)
(webmin?) のような、他のウェブインターフェースでは、カスタマイズが必要だと思われます。


== Code 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.
あなたがMoodleコードをカスタマイズしていない場合、いつでも新しいコードをダウンロードすることができます。しかし、他のバックアップと共に、Moodleコードを独自に保存することは良い考え方です。これは、あなたがカスタマイズしている場合は、大変重要なこととなります。バックアップの手順は、データファイルのバックアップと同じです。


= 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.
あなたが上記インストラクションに従って、Moodleサイトのバックアップを作成した場合、あなたが作成したサイトバックアップのリストア方法を理解する必要があります。以下、リストア処理を実行するための基本的な手順です。


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.
1. オリジナルのMoodleディレクトリを何か別の名称にリネームしてください (あなたは、まだ、Moodleディレクトリを保持していることになります)。そして、バックアップしたMoodleディレクトリまたは新しくダウンロードしたMoodleディレクトリをその場所に置いてください。


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.
2. あなたが、MySQLを使用している場合、データベースのバックアップファイルの拡張子は、.sql、.gzまたは.tar.gzのようになります。拡張子が.tar.gzまたは.gzの場合、sqlファイルになるまで、解凍してください。


  tar -xzvf moodlesqlfile.tar.gz
  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).
3. あなたがMySQLを実行している場合、MySQLサーバで新しく作成したデータベースにSQLファイルをインポートします。いくつかのバックアップでは、Moodleが動作している同じデータベースに対して、インポートを試みますので、注意してください。これは、インストール済みMoodleにダメージを与えるデータベース問題を発生させる可能性があります。これをするための最良の方法は、新しいデータベースを作成して、その中にバックアップされたデータベースをリストアすることです。そして、Moodle設定ファイル「config.php」を修正して、新しいデータベースに接続するようにします (これにより、オリジナルのデータベースを保持することができます)


Once you have created the new database:
あなたが新しいデータベースを作成した後、次のコマンドを実行します:


  mysql -p new_database < moodlesqlfile.sql
  mysql -p new_database < moodlesqlfile.sql
89行目: 86行目:
== 関連情報 ==
== 関連情報 ==


*[[Backup and restore FAQ]]
*[[バックアップおよびリストアFAQ]]
*[[Automated course backup]]
*[[自動コースバックアップ]]
*The section "Backup important data" in [[Upgrading]]
*[[アップグレード]]の「重要なデータをバックアップする」セクション
*[http://www.moodletutorials.org/view_video.php?viewkey=e257e44aa9d5bade97ba Video showing how to backup a whole Moodle site (on Linux)]
*[http://www.moodletutorials.org/view_video.php?viewkey=e257e44aa9d5bade97ba Video showing how to backup a whole Moodle site (on Linux)] - 英語
*[http://youtube.com/watch?v=ufAmf_jm_p8 Video showing how to backup a whole Moodle site (on Windows)]
*[http://youtube.com/watch?v=ufAmf_jm_p8 Video showing how to backup a whole Moodle site (on Windows)] - 英語


[[Category:バックアップ]]
[[Category:バックアップ]]


[[en:Site_backup]]
[[en:Site_backup]]

2009年8月19日 (水) 16:29時点における最新版

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

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

Moodleシステムは、下記3つの部分から成ります:

  1. データが保存されているデータベース
  2. ディスクに保存された、アップロードおよびその他のデータファイル
  3. Moodleコードを含むファイル

あなたのMoodleに関して、これらすべてのデータがどこにあるのか、config.phpにより確認することができます。どのデータベースおよびデータを使用すべきか、Moodleに伝えるため、いくつかのパラーメータがあります:

  1. $CFG->dataroot では、データファイルをどこに保存するか、コントロールします。そして、
  2. $CFG->dirroot では、Moodleコードが保存される場所を示します。

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

データベース

あなたがMoodleをバックアップするには、2つの中心的なデータがあります - データベースおよびアップロードファイルです。あなたが必要な場合、いつでも最新のデータをダウンロードできるため、Moodleスクリプト自体は、それほど重要ではありません。

バックアップには、数多くの方法があります。以下、あなたがUnixでデータベースをバックアップするための、小さなスクリプトの概略です (cronタスクを使って、日々動作させるスクリプトとして有用です):

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

文字コード

Moodleデータベースすべてをダンプする場合、管理者は起こり得る文字コード問題に関して、慎重になるべきです。場合によっては、mysqldumpまたはphpMyAdminによって作成されるバックアップは、すべてのデータを適切にエンコードできず、結果として文字化けが発生してしまいます。1つの解決方法は、MySQL Administrator 1.1または、データのUTF-8ダンプを強制する、別のツールを使用することです。

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

  • phpMyAdmin 多くのウェブホスティングプロバイダが選択するツールです。
  • MySQLDumper MySQLデータベース用バックアップスクリプトです。PHPおよびPerlで書かれています。MySQLDumperでは、PHPスクリプト実行時の中断 (通常、最大実行時間は30秒です) を避けるための独自技術を使用しています。MySQLDumperは、上記で指摘された文字コード問題にも対応しています。また、圧縮ファイルでも動作します。

データファイル

ファイルに関して、変更されたファイルのみ別のホストにコピーするため、あなたは定期的にrsyncコマンドを使用することができます:

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

あなたが、Moodleを動作させているマシンでcronスクリプトを実行させたい場合、次のrsync構文を使用してください:

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

あなたが、rsyncのステータスメールでrootメールボックスを一杯にしたくない場合、次のrsync構文を使用してください:

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

あなたのMoodleホスティングプロバイダがsshを許可しない場合 (または、単に提供していない場合)、そしてあなたがユーザ名およびパスワードを使ってFTPアクセスできる場合、次のコマンドも使用できます:

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

データベースすべてのバックアップは、次のコマンドで実行できます (cPanelウェブインターフェースでテスト済み):

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

そして、Moodleコードツリーすべてのバックアップは、次のコマンドで実行できます:

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

(webmin?) のような、他のウェブインターフェースでは、カスタマイズが必要だと思われます。

コードファイル

あなたがMoodleコードをカスタマイズしていない場合、いつでも新しいコードをダウンロードすることができます。しかし、他のバックアップと共に、Moodleコードを独自に保存することは良い考え方です。これは、あなたがカスタマイズしている場合は、大変重要なこととなります。バックアップの手順は、データファイルのバックアップと同じです。

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

あなたが上記インストラクションに従って、Moodleサイトのバックアップを作成した場合、あなたが作成したサイトバックアップのリストア方法を理解する必要があります。以下、リストア処理を実行するための基本的な手順です。

1. オリジナルのMoodleディレクトリを何か別の名称にリネームしてください (あなたは、まだ、Moodleディレクトリを保持していることになります)。そして、バックアップしたMoodleディレクトリまたは新しくダウンロードしたMoodleディレクトリをその場所に置いてください。

2. あなたが、MySQLを使用している場合、データベースのバックアップファイルの拡張子は、.sql、.gzまたは.tar.gzのようになります。拡張子が.tar.gzまたは.gzの場合、sqlファイルになるまで、解凍してください。

tar -xzvf moodlesqlfile.tar.gz

3. あなたがMySQLを実行している場合、MySQLサーバで新しく作成したデータベースにSQLファイルをインポートします。いくつかのバックアップでは、Moodleが動作している同じデータベースに対して、インポートを試みますので、注意してください。これは、インストール済みMoodleにダメージを与えるデータベース問題を発生させる可能性があります。これをするための最良の方法は、新しいデータベースを作成して、その中にバックアップされたデータベースをリストアすることです。そして、Moodle設定ファイル「config.php」を修正して、新しいデータベースに接続するようにします (これにより、オリジナルのデータベースを保持することができます)。

あなたが新しいデータベースを作成した後、次のコマンドを実行します:

mysql -p new_database < moodlesqlfile.sql

関連情報