{"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 \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":"\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":"