{"id":747,"date":"2020-08-21T09:23:10","date_gmt":"2020-08-21T01:23:10","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=747"},"modified":"2021-04-02T16:55:25","modified_gmt":"2021-04-02T08:55:25","slug":"wordpress-backup-script","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/","title":{"rendered":"WordPress \u5907\u4efd\u811a\u672c"},"content":{"rendered":"\n

\u4e00\u5468\u5907\u4efd\u4e00\u6b21\uff0c\u5b9a\u65f6\u4efb\u52a1 <\/em> <\/em> 1 <\/p>\n\n\n

#\/bin\/bash\n#set -x \n#\u6574\u4f53\u6253\u5305wordpress\ncd \/root\/backup\/\nold_back=date -d "-7 day" +%Y%m%d<\/code>\nnew_back=date +%Y%m%d<\/code>\ndate=date "+%Y-%m-%d %H:%M:%S"<\/code>\n#\u5220\u9664\nfunction del(){\n    if [ -f  wordpress-v${old_back}.tar.gz ];then\n        rm -f wordpress-v${old_back}.tar.gz\n        echo \"\u5220\u9664\u65e7\u5907\u4efd\u6587\u4ef6\uff1a wordpress-v${old_back}.tar.gz\" >> \/root\/backup\/backup.log\n    fi\n    if [ -f  wordpress-${old_back}.sql ];then\n        rm -f wordpress-${old_back}.sql\n        echo \"\u5220\u9664\u65e7\u5907\u4efdsql\uff1a wordpress-${old_back}.sql \">> \/root\/backup\/backup.log\n    fi\n}\n#\u5907\u4efd\nfunction back(){\n\n    echo \"\u5f00\u59cb\u65f6\u95f4\uff1a\" $date >> \/root\/backup\/backup.log\n    echo $date\">>\u5907\u4efdwordpress\" >> \/root\/backup\/backup.log\n#wordpress \u5907\u4efd\n    tar -zcvf wordpress-v${new_back}.tar.gz  \/var\/www\/wordpress\n\n#mysql \u6570\u636e\u5e93\u5907\u4efd\n    echo $date\">>\u5907\u4efdwordpress\u6570\u636e\u5e93\"  >> \/root\/backup\/backup.log\n    mysqldump   --defaults-extra-file=\/etc\/my.cnf  wordpress > .\/wordpress-${new_back}.sql \n}\nback\nif [ $? -eq 0 ];then\n    echo \"\u5907\u4efd\u6210\u529f\uff01\" >> \/root\/backup\/backup.log\n    del\nelse\n    echo \"\u5907\u4efd\u5931\u8d25\uff01\" $date >> \/root\/backup\/backup.log\nfi\n    echo \"\u7ed3\u675f\u65f6\u95f4\uff1a\" $date >> \/root\/backup\/backup.log\n    echo -e \"\\n\" >> \/root\/backup\/backup.log\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

\u4e00\u5468\u5907\u4efd\u4e00\u6b21\uff0c\u5b9a\u65f6\u4efb\u52a1 1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,14],"tags":[],"yoast_head":"\nWordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u5468\u5907\u4efd\u4e00\u6b21\uff0c\u5b9a\u65f6\u4efb\u52a1 1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-21T01:23:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-02T08:55:25+00:00\" \/>\n<meta name=\"author\" content=\"\u7ba1\u7406\u5458\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\"},\"author\":{\"name\":\"\u7ba1\u7406\u5458\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"headline\":\"WordPress \u5907\u4efd\u811a\u672c\",\"datePublished\":\"2020-08-21T01:23:10+00:00\",\"dateModified\":\"2021-04-02T08:55:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\"},\"wordCount\":1,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"articleSection\":[\"Linux\",\"Shell\"],\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\",\"name\":\"Wordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\"},\"datePublished\":\"2020-08-21T01:23:10+00:00\",\"dateModified\":\"2021-04-02T08:55:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#breadcrumb\"},\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.linuxdevops.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/www.linuxdevops.cn\/linux\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"WordPress \u5907\u4efd\u811a\u672c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\",\"url\":\"https:\/\/www.linuxdevops.cn\/\",\"name\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"description\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0\",\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"alternateName\":\"linuxdevops\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.linuxdevops.cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-CN\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\",\"name\":\"\u7ba1\u7406\u5458\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"contentUrl\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"width\":512,\"height\":512,\"caption\":\"\u7ba1\u7406\u5458\"},\"logo\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\"},\"description\":\"\u7ba1\u7406\u5458\",\"url\":\"https:\/\/www.linuxdevops.cn\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/","og_locale":"zh_CN","og_type":"article","og_title":"Wordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","og_description":"\u4e00\u5468\u5907\u4efd\u4e00\u6b21\uff0c\u5b9a\u65f6\u4efb\u52a1 1","og_url":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/","og_site_name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","article_published_time":"2020-08-21T01:23:10+00:00","article_modified_time":"2021-04-02T08:55:25+00:00","author":"\u7ba1\u7406\u5458","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#article","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/"},"author":{"name":"\u7ba1\u7406\u5458","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"headline":"WordPress \u5907\u4efd\u811a\u672c","datePublished":"2020-08-21T01:23:10+00:00","dateModified":"2021-04-02T08:55:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/"},"wordCount":1,"commentCount":0,"publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"articleSection":["Linux","Shell"],"inLanguage":"zh-CN","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/","url":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/","name":"Wordpress \u5907\u4efd\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/#website"},"datePublished":"2020-08-21T01:23:10+00:00","dateModified":"2021-04-02T08:55:25+00:00","breadcrumb":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#breadcrumb"},"inLanguage":"zh-CN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.linuxdevops.cn\/2020\/08\/wordpress-backup-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.linuxdevops.cn\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/www.linuxdevops.cn\/linux\/"},{"@type":"ListItem","position":3,"name":"WordPress \u5907\u4efd\u811a\u672c"}]},{"@type":"WebSite","@id":"https:\/\/www.linuxdevops.cn\/#website","url":"https:\/\/www.linuxdevops.cn\/","name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","description":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0","publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"alternateName":"linuxdevops","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.linuxdevops.cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-CN"},{"@type":["Person","Organization"],"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1","name":"\u7ba1\u7406\u5458","image":{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/","url":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","contentUrl":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","width":512,"height":512,"caption":"\u7ba1\u7406\u5458"},"logo":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/"},"description":"\u7ba1\u7406\u5458","url":"https:\/\/www.linuxdevops.cn\/author\/root\/"}]}},"_links":{"self":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/747"}],"collection":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":2,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/747\/revisions"}],"predecessor-version":[{"id":1000,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/747\/revisions\/1000"}],"wp:attachment":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/categories?post=747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/tags?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}