{"id":77,"date":"2018-11-08T09:14:39","date_gmt":"2018-11-08T09:14:39","guid":{"rendered":"https:\/\/jan.schnasse.org\/blog\/?p=77"},"modified":"2018-11-08T09:14:39","modified_gmt":"2018-11-08T09:14:39","slug":"backup-mysql","status":"publish","type":"post","link":"https:\/\/jan.schnasse.org\/blog\/2018\/11\/08\/backup-mysql\/","title":{"rendered":"Backup MySQL"},"content":{"rendered":"<p>This is how I backup MySQL databases.<\/p>\n<p>Solution consists of three files<\/p>\n<ul>\n<li><a href=\"https:\/\/gist.github.com\/jschnasse\/2652bfad3dc8625dc00b1826a9c66409#file-backup-db-sh\">backup-db.sh<\/a><\/li>\n<li><a href=\"https:\/\/gist.github.com\/jschnasse\/2652bfad3dc8625dc00b1826a9c66409#file-variables-conf\">variables.conf<\/a><\/li>\n<li><a href=\"https:\/\/gist.github.com\/jschnasse\/2652bfad3dc8625dc00b1826a9c66409#file-crontab\">crontab entry<\/a><\/li>\n<\/ul>\n<p>Find <a href=\"https:\/\/gist.github.com\/jschnasse\/2652bfad3dc8625dc00b1826a9c66409\">complete solution here<\/a><\/p>\n<p>The <em>backup-db.sh<\/em> is called every day with Parameter<em> -b<\/em> for <em>backup<\/em> and with parameter <em>-c<\/em> for <em>cleanup<\/em>. The <em>backup<\/em> routine dumps all MySQL databases into one file. The\u00a0 <em>cleanup<\/em> routine removes old backups (older than 30 days, see <em>LIMIT<\/em> variable). The restore routine requires to hardcode a certain snapshot into the script. The <em>variables.conf <\/em>must be placed in same folder as <em>backup-db.sh .<\/em><\/p>\n<p>This is how the backup folder looks after running the script for 32 days at 23h.<\/p>\n<p>20181009-023001.sql 20181020-023001.sql 20181031-023001.sql<br \/>\n20181010-023001.sql 20181021-023001.sql 20181101-023001.sql<br \/>\n20181011-023001.sql 20181022-023001.sql 20181102-023001.sql<br \/>\n20181012-023001.sql 20181023-023001.sql 20181103-023001.sql<br \/>\n20181013-023001.sql 20181024-023001.sql 20181104-023001.sql<br \/>\n20181014-023001.sql 20181025-023001.sql 20181105-023001.sql<br \/>\n20181015-023001.sql 20181026-023002.sql 20181106-023001.sql<br \/>\n20181016-023001.sql 20181027-023001.sql 20181107-023001.sql<br \/>\n20181017-023001.sql 20181028-023001.sql 20181108-023001.sql<br \/>\n20181018-023001.sql 20181029-023002.sql<br \/>\n20181019-023001.sql 20181030-023001.sql<\/p>\n<p>The folder will contain backups for the last 31 days.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is how I backup MySQL databases. Solution consists of three files backup-db.sh variables.conf crontab entry Find complete solution here The backup-db.sh is called every day with Parameter -b for backup and with parameter -c for cleanup. The backup routine dumps all MySQL databases into one file. The\u00a0 cleanup routine removes old backups (older than [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-admin"],"_links":{"self":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":0,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}