{"id":873,"date":"2017-09-01T17:30:13","date_gmt":"2017-09-01T08:30:13","guid":{"rendered":"http:\/\/www.dogrow.net\/php\/?p=873"},"modified":"2018-08-25T22:24:06","modified_gmt":"2018-08-25T13:24:06","slug":"blog33","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/php\/blog33\/","title":{"rendered":"(33) \u3010WORDPRESS\u3011\u30d7\u30e9\u30b0\u30a4\u30f3\u3067WORDPRESS\u3092\u5b8c\u5168\u30d0\u30c3\u30af\u30a2\u30c3\u30d7"},"content":{"rendered":"<p>\u30b3\u30c4\u30b3\u30c4\u3068WORDPRESS\u4e0a\u306b\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u3066\u5fc3\u914d\u306b\u306a\u308b\u3053\u3068\u3001\u305d\u308c\u306f<br \/>\n\u300c\u3082\u3057\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u3066\u3057\u307e\u3063\u305f\u3089\u3069\u3046\u3057\u3088\u3046&#8230;\u300d<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306f\u3082\u3061\u308d\u3093\u306e\u3053\u3068\u3001\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u753b\u50cf\u3084\u3001\u81ea\u4f5c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bFTP\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u8af8\u3005\u306e\u30d5\u30a1\u30a4\u30eb\u305f\u3061\u304c\u6d88\u3048\u305f\u3089\u3068\u3063\u3066\u3082\u56f0\u308a\u307e\u3059\u3002<\/p>\n<h1 class=\"my_h\">\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p class=\"my_fs_big2 my_fc_deeppink\">\n\u5bfe\u8c611: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<br \/>\n\u5bfe\u8c612: WORDPRESS\u8a2d\u7f6e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306e\u5168\u30d5\u30a1\u30a4\u30eb<\/p>\n<p>\u3092 <span class=\"my_fs_big2 my_fc_deeppink\">\u5b8c\u5168\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3057\u305f\u3044<\/span> \u3068\u8003\u3048\u307e\u3057\u305f\u3002<\/p>\n<p>WORDPRESS\u306e\u30c7\u30fc\u30bf\u3092\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u63a2\u3057\u307e\u3057\u305f\u304c\u3001\u9ad8\u6a5f\u80fd\u306a\u7269\u3070\u304b\u308a\u3067\u3069\u308c\u3092\u4f7f\u304a\u3046\u304b\u8ff7\u3063\u3066\u3057\u307e\u3046&#8230;<br \/>\n\u305d\u3053\u3067\u3001\u81ea\u5206\u306e\u6c42\u3081\u308b\u30d4\u30c3\u30bf\u30ea\u30b5\u30a4\u30ba\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u81ea\u4f5c\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h1 class=\"my_h\">\u30d7\u30ed\u30b0\u30e9\u30e0<\/h1>\n<p class=\"my_mgB_0\">WORDPRESS\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30de\u30ca\u30fc\u306b\u5f93\u3063\u3066\u3044\u308b\u306e\u304b\u3069\u3046\u304b\u751a\u3060\u5fc3\u914d\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3084\u308a\u305f\u3044\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p class=\"my_fc_red my_mgB_0\">\u203bWORDPRESS, PHP\u304c <span class=\"my_fs_big3\">Linux<\/span> \u4e0a\u3067\u52d5\u3044\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u306b\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3 class=my_h>backup_all.php<\/h3>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\/*\r\nPlugin Name:  Backup All\r\n*\/\r\nif (class_exists('BackupAll')) {\r\n  $obj = new BackupAll();\r\n}\r\nclass BackupAll {\r\n  private $m_filename_prefix;\r\n  public function __construct() {\r\n    $this-&gt;m_filename_prefix = 'wordpress_backupall_';\r\n    add_action('admin_menu',   array($this,'proc_add_menu'));\r\n  }\r\n  public function proc_add_menu() {\r\n    add_submenu_page('options-general.php', 'BackupAll Settings', 'BackupAll', 'administrator', __FILE__, array($this,'proc_display_setting_page'));\r\n  }\r\n  public function execute_backup_db( &amp;$o_dump_file_db_url ){\r\n    $ret = FALSE;\r\n    $cmd = &quot;rm &quot;.ABSPATH.$this-&gt;m_filename_prefix.&quot;DB_mysql_*&quot;;\r\n    exec($cmd, $resp, $code);\r\n    $fname_body = strftime($this-&gt;m_filename_prefix.&quot;DB_mysql_%Y%m%d%H%M&quot;, time());\r\n    $fpath_sql = ABSPATH.$fname_body.&quot;.sql&quot;;\r\n    $fpath_zip = ABSPATH.$fname_body.&quot;.zip&quot;;\r\n    $cmd = &quot;\/usr\/local\/mysql\/bin\/mysqldump &quot;.DB_NAME.&quot; --host=&quot;.DB_HOST.&quot; -u &quot;.DB_USER.&quot; --password=&quot;.DB_PASSWORD.&quot; -e &gt; {$fpath_sql}; zip {$fpath_zip} {$fpath_sql}; rm {$fpath_sql}&quot;;\r\n    exec($cmd, $resp, $code);\r\n    $o_dump_file_db_url = home_url($fname_body.&quot;.zip&quot;);\r\n    $ret = TRUE;\r\ntagEND:\r\n    return $ret;\r\n  }\r\n  public function execute_backup_file( &amp;$o_dump_file_files_url ){\r\n    $ret = FALSE;\r\n    $cmd = &quot;rm &quot;.ABSPATH.$this-&gt;m_filename_prefix.&quot;files_*&quot;;\r\n    exec($cmd, $resp, $code);\r\n    $fname = strftime($this-&gt;m_filename_prefix.&quot;files_%Y%m%d%H%M.zip&quot;, time());\r\n    $fpath = ABSPATH.$fname;\r\n    $cmd = &quot;zip {$fpath} -r &quot;.ABSPATH;\r\n    exec($cmd, $resp, $code);\r\n    $o_dump_file_files_url = home_url($fname);\r\n    $ret = TRUE;\r\ntagEND:\r\n    return $ret;\r\n  }\r\n  public function proc_display_setting_page(){\r\n    $html_download = &quot;&quot;;\r\n    \/\/ execute backup?\r\n    if(TRUE === isset($_POST&#x5B;'ytmr_exec_backup'])){\r\n      $this-&gt;execute_backup_db($dump_file_db_url);\r\n      $link_to_dump_file = &quot;&lt;p&gt;&lt;a href='{$dump_file_db_url}'&gt;&quot;.basename($dump_file_db_url).&quot;&lt;\/a&gt;&lt;\/p&gt;&quot;;\r\n      if($_POST&#x5B;'ytmr_exec_backup'] == 2){\r\n        $this-&gt;execute_backup_file($dump_file_files_url);\r\n        $link_to_dump_file = &quot;&lt;p&gt;&lt;a href='{$dump_file_files_url}'&gt;&quot;.basename($dump_file_files_url).&quot;&lt;\/a&gt;&lt;\/p&gt;&quot;;\r\n      }\r\n$html_download .= &lt;&lt;&lt; EOM\r\n&lt;div&gt;\r\n  &lt;div style=&quot;padding:0.5rem;background-color:#fff;border:2px #00f solid;line-height:1.2&quot;&gt;\r\n&lt;p style=&quot;font-size:1.2rem&quot;&gt;Download and save backup files below.&lt;\/p&gt;\r\n{$link_to_dump_file}\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\nEOM;\r\n    }\r\necho &lt;&lt;&lt; EOM\r\n&lt;div class=&quot;wrap&quot;&gt;\r\n{$html_download}\r\n&lt;h2&gt;Backup this wordpress ALL (Linux only)&lt;\/h2&gt;\r\n&lt;form id=&quot;BackupAll&quot; method=&quot;post&quot; action=&quot;{$_SERVER&#x5B;'REQUEST_URI']}&quot;&gt;\r\n  &lt;p&gt;&lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;ytmr_exec_backup&quot; value=&quot;1&quot; \/&gt;backup database only&lt;\/label&gt;&lt;\/p&gt;\r\n  &lt;p&gt;&lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;ytmr_exec_backup&quot; value=&quot;2&quot; checked \/&gt;backup database and all files&lt;\/label&gt;&lt;\/p&gt;\r\nEOM;\r\n    submit_button('Execute Backup');\r\necho &lt;&lt;&lt; EOM\r\n&lt;\/form&gt;\r\n&lt;\/div&gt;\r\nEOM;\r\n  }\r\n}   \/\/ end of class\r\n?&gt;\r\n<\/pre>\n<h1 class=\"my_h\">\u4f7f\u3044\u65b9<\/h1>\n<h3 class=my_h>(1) \u30d7\u30e9\u30b0\u30a4\u30f3\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/h3>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\uff08\u6587\u5b57\u30b3\u30fc\u30c9 UTF-8\uff09backup_all.php \u3068\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<br \/>\n\u4f5c\u6210\u3057\u305f\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092 backup_all.zip \u306b\u5727\u7e2e\u3057\u307e\u3059\u3002<\/p>\n<h3 class=my_h>(2) \u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>WORDPRESS\u306e\u7ba1\u7406\u753b\u9762\u3067 [\u30d7\u30e9\u30b0\u30a4\u30f3]\uff0d[\u65b0\u898f\u8ffd\u52a0]\u30e1\u30cb\u30e5\u30fc\u3092\u9078\u629e\u3057\u3001(1)\u3067\u4f5c\u6210\u3057\u305fZIP\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u51fa\u6765\u305f\u3089\u300c\u6709\u52b9\u5316\u300d\u3057\u307e\u3059\u3002<\/p>\n<h3 class=my_h>(3) \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u5b9f\u884c<\/h3>\n<p>\u7ba1\u7406\u753b\u9762\u3067 [\u8a2d\u5b9a]\uff0d[BackupAll]\u30e1\u30cb\u30e5\u30fc\u3092\u9078\u629e\u3057\u307e\u3059\u3002<br \/>\n\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5bfe\u8c61\u300cDB\u306e\u307f\u300dor\u300cDB\u3068\u5168\u30d5\u30a1\u30a4\u30eb\u300d\u306e\u3069\u3061\u3089\u304b\u3092\u9078\u629e\u3057\u3001[\u5b9f\u884c]\u30dc\u30bf\u30f3\u3092\u62bc\u4e0b\u3057\u307e\u3059\u3002<br \/>\n<img decoding=\"async\" src=\"\/\/www.dogrow.net\/php\/wp-content\/uploads\/2017\/09\/Image2.png\" alt=\"\" \/><br \/>\n\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u304c\u5b8c\u4e86\u3059\u308b\u3068\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30ea\u30f3\u30af\u304c\u51fa\u73fe\u3057\u307e\u3059\u306e\u3067\u3001\u3053\u308c\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n<img decoding=\"async\" src=\"\/\/www.dogrow.net\/php\/wp-content\/uploads\/2017\/09\/Image4.png\" alt=\"\" \/><br \/>\n\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u7528HDD\u306a\u3069\u306b\u5165\u308c\u3066\u5927\u5207\u306b\u4fdd\u7ba1\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<div class=\"my_fc_red\">\u203b\u4f5c\u6210\u3057\u305f\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308bUI\u306f\u672a\u5b9f\u88c5\u3067\u3059\u3002\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5b9f\u884c\u6642\u306b\u53e4\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u81ea\u52d5\u524a\u9664\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3069\u3093\u3069\u3093\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u304c\u80a5\u5927\u5316\u3057\u3066\u3044\u304f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/div>\n<hr class=my_hr_bottom>\n","protected":false},"excerpt":{"rendered":"<p>\u30b3\u30c4\u30b3\u30c4\u3068WORDPRESS\u4e0a\u306b\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u3066\u5fc3\u914d\u306b\u306a\u308b\u3053\u3068\u3001\u305d\u308c\u306f \u300c\u3082\u3057\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u3066\u3057\u307e\u3063\u305f\u3089\u3069\u3046\u3057\u3088\u3046&#8230;\u300d \u3068\u3044\u3046\u3053\u3068\u3002 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306f\u3082\u3061\u308d\u3093\u306e\u3053\u3068\u3001\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u753b\u50cf\u3084\u3001\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/php\/blog33\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,11],"tags":[],"class_list":["post-873","post","type-post","status-publish","format-standard","hentry","category-mysql","category-wordpress"],"views":1558,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/873","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/comments?post=873"}],"version-history":[{"count":37,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/873\/revisions"}],"predecessor-version":[{"id":1582,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/873\/revisions\/1582"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/media?parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/categories?post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/tags?post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}