{"id":21,"date":"2012-12-23T11:43:44","date_gmt":"2012-12-23T02:43:44","guid":{"rendered":"https:\/\/lonelyse.campus-web.net\/?p=21"},"modified":"2014-05-15T18:35:37","modified_gmt":"2014-05-15T09:35:37","slug":"mysql%e3%81%aedb%e5%90%8d%e3%82%92%e8%87%aa%e5%8b%95%e3%81%a7%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e5%80%8b%e3%80%85%e3%81%ab%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97dump%e3%81%99","status":"publish","type":"post","link":"https:\/\/lonelyse.campus-web.net\/?p=21","title":{"rendered":"MySQL\u306eDB\u540d\u3092\u81ea\u52d5\u3067\u53d6\u5f97\u3057\u3066\u500b\u3005\u306b\u30d0\u30c3\u30af\u30a2\u30c3\u30d7(DUMP)\u3059\u308b"},"content":{"rendered":"<p>\n\tDB\u540d\u3092\u52dd\u624b\u306b\u53d6\u5f97\u3057\u3066\u3001DUMP\u3092\u53d6\u308c\u306a\u3044\u3060\u308d\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u304a\u5ba2\u69d8\u306b\u307e\u305f\u8cb8\u3057\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d0\u3092\u904b\u7528\u3057\u3066\u3044\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u58c1\u306b\u3076\u3061\u5f53\u305f\u308a\u307e\u3057\u305f\u3002\uff08\u30b5\u30fc\u30d0\u7ba1\u7406\u8005\u5411\u3051\uff09\n<\/p>\n<p>\n\t<!--more-->\n<\/p>\n<p>\n\t<a href=\"http:\/\/lonelyse.campus-web.net\/wp-content\/uploads\/2012\/12\/spec-mysql.jpg\" rel=\"attachment wp-att-22\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-22\" height=\"100\" src=\"http:\/\/lonelyse.campus-web.net\/wp-content\/uploads\/2012\/12\/spec-mysql.jpg\" title=\"spec-mysql\" width=\"300\" \/><\/a>\n<\/p>\n<p>\n\tMySQL\u306e\u30c7\u30fc\u30bf\u3092\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u306b\u306f\u3001MySQL\u4ed8\u5c5e\u306e\u30b3\u30de\u30f3\u30c9\u3067DUMP\u304c\u6709\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u4f7f\u3046\u306b\u306f\u3001\u6761\u4ef6\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<p>\n\t<strong>\u25a0DB\u3092\u6307\u5b9a\u3057\u3066DUMP\u3092\u3068\u308b<\/strong><br \/>\n\t<span style=\"color:#ff0000;\">&rArr;\u6b20\u70b9<\/span><br \/>\n\t\u30fb\u5404\u30e6\u30fc\u30b6\u306b\u3068\u3063\u3066\u3082\u3089\u308f\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3002SSH\u304c\u958b\u653e\u3067\u304d\u306a\u3044\u5834\u5408\u306fphpMyAdmin\u3067\u624b\u52d5\u3067\u53d6\u308b\u3002\uff08\u6709\u6599\u30bd\u30d5\u30c8\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\uff09<br \/>\n\t\u30fb\u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u3044\u306a\u3044\u5236\u4f5c\u4f1a\u793e\u3084\u304a\u5ba2\u69d8\u306b\u306f\u5c11\u3005\u6577\u5c45\u304c\u9ad8\u3044\u3002<br \/>\n\t\u30fb\u30b7\u30a7\u30eb\u3067\uff11\u3064\uff11\u3064DB\u540d\u3092\u66f8\u3044\u3066\u3044\u3051\u3070DUMP\u3092\u3068\u308c\u308b\u304c\u3001\u3053\u308c\u306f<strong>\u534a\u624b\u52d5<\/strong>\u306a\u3082\u306e\u3067\u3042\u308a\u3001\u3057\u304b\u3082\u6f0f\u308c\u308b\u53ef\u80fd\u6027\u304c\u591a\u3044\u3002\n<\/p>\n<p>\n\t<strong>\u25a0DB\u3092\u307e\u308b\u307e\u308b\uff11\u3064\u306eDUMP\u306broot\u6a29\u9650\u3067\u53d6\u308b\u3002<\/strong><br \/>\n\t<span style=\"color:#ff0000;\">&rArr;\u6b20\u70b9<\/span><br \/>\n\t\uff11\u3064\u306e\u30c7\u30fc\u30bf\u306b\u53ce\u7d0d\u3059\u308b\u305f\u3081\u3001\u500b\u5225\u306eDB\u3092DUMP\u3067\u623b\u3059\u3068\u304d\u304c\u30e1\u30f3\u30c9\u30af\u30b5\u30a4\u3002\u30c7\u30fc\u30bf\u304c\u5927\u304d\u304f\u306a\u308c\u3070\u3001<strong>\u5207\u308a\u51fa\u3059\u306e\u304c\u975e\u5e38\u306b\u56f0\u96e3\u3002<\/strong>\n<\/p>\n<p>\n\tDUMP\u306e\u30b3\u30de\u30f3\u30c9\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u76f8\u5f53\u63a2\u3057\u307e\u3057\u305f\u304c\u3001\u4e0a\u8a18\uff12\u3064\u4ee5\u5916\u306e<span style=\"color:#ff0000;\">DUMP\u30b3\u30de\u30f3\u30c9\u5358\u4f53\u3067\u53d6\u308b\u65b9\u6cd5\u306f\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/span>\n<\/p>\n<p>\n\t\u305d\u3053\u3067\u3001<a href=\"http:\/\/gihyo.jp\/admin\/serial\/01\/cosmi\/0001\" target=\"_blank\">AWS<\/a>\uff08\u30a2\u30de\u30be\u30f3\u306e\u30af\u30e9\u30a6\u30c9\u3067\u306f\u3042\u308a\u307e\u305b\u3093^^\uff09\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u30b7\u30a7\u30eb\u3067\u53ef\u80fd\u306a\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n\t<strong>\u25a0\u4eca\u56de\u306e\u3084\u308a\u305f\u3044\u3053\u3068<\/strong><br \/>\n\t<span style=\"font-size:12px;\"><span style=\"font-family: arial, sans-serif;\">\u30fb\u30b7\u30a7\u30eb\u3067\u5168\u81ea\u52d5\u5316\u3057\u305f\u3044<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif;\">\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3054\u3068\u306eDUMP\u3092\u500b\u5225\u306b\u53d6\u308a\u305f\u3044\u3002<\/span><\/span>\n<\/p>\n<p>\n\t<strong><span style=\"font-size:12px;\"><span style=\"font-family: arial, sans-serif;\">\u25a0\u30b7\u30a7\u30eb\u306e\u5185\u5bb9\uff08DUMP\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u500b\u3005\u306e\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u304f\u3060\u3055\u3044\uff09<\/span><\/span><\/strong>\n<\/p>\n<p>\n\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span>\n<\/p>\n<p>\n\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">#!\/bin\/bash<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">_wdate=`date +&quot;%Y%m%d%H%M%S&quot;`<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">_backupdir=&quot;xxxx\/&quot;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">_backupfilepath=&quot;${_backupdir}<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">&quot;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">_dbuserid=xxxx<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">_dbpasswd=xxxx\u3000&larr;<span style=\"color:#ff0000;\">MySQLroot\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059<\/span><\/span>\n<\/p>\n<p>\n\t<br \/>\n\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\"># \u30b9\u30ad\u30fc\u30de\u540d\u306e\u307f\u3092\u3001<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">awk\u3067\u62bd\u51fa\u3057\u3066\u62bd\u51fa\u3057\u305f\u30b9\u30ad\u30fc\u30de\u5206\u306emysqldump\u3092\u5b9f\u884c<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">\u3059\u308b<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">for n in `mysql -N -u ${_dbuserid} -p${_dbpasswd} -e &quot;show databases&quot;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">| awk &#39;{ print $0 }&#39;`; do &nbsp;echo &quot;BackupDirectory &gt;&gt;&nbsp;<\/span><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">${_backupfilepath}\/${HOSTNAME}<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">.${n}.${_wdate}.${HOSTNAME}.<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">dump&quot;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">mysqldump -u ${_dbuserid} -p${_dbpasswd} ${n} &gt;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">${_backupfilepath}\/${HOSTNAME}<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">.${n}.`date +%y%m%d`.dump;<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">done<\/span><br style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><\/p>\n<p>\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">exit 0<\/span><br \/>\n\t<span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><wbr style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\" \/><span style=\"font-family: arial, sans-serif; font-size: 13.63636302947998px;\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span>\n<\/p>\n<p>\n\t\u3068\u3044\u3063\u305f\u611f\u3058\u3067\u3001\u610f\u5916\u306b\u3082\u7c21\u5358\u306b\u3067\u304d\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n\t\u3042\u3068\u306f\u3001\u3053\u308c\u306b.sh\u306e\u62e1\u5f35\u5b50\u3092\u3064\u3051\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3002\u5b9f\u884c\u6a29\u9650\u3092\u4e0e\u3048\u3066\u3042\u3052\u3066cron\u3067\u5b9f\u884c\u3059\u308b\u3068\u3044\u3046\u5f62\u3067\u3059\u3002cron\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u306f\u3001\u30cd\u30c3\u30c8\u4e0a\u306b\u6ca2\u5c71\u60c5\u5831\u304c\u3042\u308b\u306e\u3067\u5272\u611b\u3057\u307e\u3059\u3002\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p><script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-9057618403394079\";\r\n\/* \u57fa\u672c\u5e83\u544a *\/\r\ngoogle_ad_slot = \"6529398585\";\r\ngoogle_ad_width = 728;\r\ngoogle_ad_height = 90;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script><\/p>\n<div class=\"fb-like\" data-href=\"https:\/\/lonelyse.campus-web.net\" data-send=\"true\" data-show-faces=\"true\" data-width=\"450\">\n\t&nbsp;\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>DB\u540d\u3092\u52dd\u624b\u306b\u53d6\u5f97\u3057\u3066\u3001DUMP\u3092\u53d6\u308c\u306a\u3044\u3060\u308d\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u304a\u5ba2\u69d8\u306b\u307e\u305f\u8cb8\u3057\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d0\u3092\u904b\u7528\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":22,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql"],"views":2437,"_links":{"self":[{"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":11,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":144,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions\/144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=\/wp\/v2\/media\/22"}],"wp:attachment":[{"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lonelyse.campus-web.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}