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

提供:MoodleDocs
移動先:案内検索
42行目: 42行目:
  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/

2009年8月12日 (水) 18:41時点における版

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

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

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

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/

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

関連情報