1 views


■概要

USB外付ハードディスク(/mnt/usbhd/all/backup/)にWordPressフォルダを除きを丸ごと(/)自動でバックアップしては、サーバーを構築するごとに復元させて使っています。
USB外付ハードディスクは、HDCE1.0TU2。USBに挿せばそのまま使えますが、自動でバックアップを取るには設定が必要になります。以下、その手順です。

■要件

NTFS形式のUSBハードディスクを追加(fuse-ntfs-3g)設定が済んでいること

WordPressのバックアップを取っていること(rsync)

■USB外付ハードディスクに保存されているWordPressの復元

[root@ufuso ~]# /bin/cp -Rf /mnt/usbhd/all/backup/var/www/html/wordpress/ /var/www/html/
   ← WordPressフォルダの復元

[root@ufuso ~]# chmod -R 777 /var/www/html/wordpress/wp-content ← 書込み権限付与

[root@ufuso ~]# chown -R apache:apache /var/www/html/wordpress ← 所有者をapacheに変更

■USB外付ハードディスクに保存されているMySQLの復元

[root@ufuso ~]# /bin/cp -Rf /mnt/usbhd/all/backup/var/lib/mysql/life/ /var/lib/mysql/
 ← 復元(例示のデータベース名はlife)

[root@ufuso ~]# chown -R mysql:mysql /var/lib/mysql/life/ ← 所有者をmysqlに変更

[root@ufuso ~]# chmod 700 /var/lib/mysql/life/ ← 所有者のみに書込み許可
[root@ufuso ~]# chmod 660 /var/lib/mysql/life/* ← 所有者・グループに書込み許可
[root@ufuso ~]# mysql -u root -p ← mysqlの起動
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 9
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> grant all privileges on life.* to tu@localhost identified by 'tuのパスワード';
 ← 管理者(例示ではtu)の復元
Query OK, 0 rows affected (0.00 sec)

mysql> exit ← mysqlの終了
Bye

[root@ufuso ~]# yum install php-mysql ← phpでmysqlを使うために必要
Installed:
  php-mysql.x86_64 0:5.3.3-3.el6_2.6                                            

Dependency Installed:
  php-pdo.x86_64 0:5.3.3-3.el6_2.6                                              

Complete!

[root@ufuso ~]# /etc/init.d/httpd restart ← WEBサーバー再起動
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

※http://~/wordpressサイトにアクセスできればOK。

■.htaccessファイルが復元されない場合の対処手順(ひとつのWordPressで複数のサイトを運営している場合のみ必要)

[root@ufuso ~]# [root@ufuso ~]# cd /var/www/html/wordpress
 ← wordpressを設置しているフォルダに移動(例示はhtmlの下に置いてある場合)

[root@ufuso ~]# vi .htaccess ← 復元できていない場合は、何も表示されないので、下記を
コピペする(ただし、子サイトをサブフォルダ方式で作成している場合の例です)

RewriteEngine On
RewriteBase /wordpress/ ← .htaccessファイルを置いてある場所を指定(例示ではwordpress
フォルダ内)
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

子サイトをサブドメイン方式で作成している場合は以下をコピペ

RewriteEngine On
RewriteBase /wordpress/ ← .htaccessファイルを置いてある場所を指定(例示ではwordpress
フォルダ内)
RewriteRule ^index.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

[root@ufuso ~]# /etc/init.d/httpd restart ← WEBサーバー再起動
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください