{"id":40,"date":"2016-06-14T23:07:13","date_gmt":"2016-06-14T23:07:13","guid":{"rendered":"http:\/\/188.223.144.42:4130\/?p=15"},"modified":"2016-06-14T23:07:13","modified_gmt":"2016-06-14T23:07:13","slug":"house-keeping-the-sql-dumps","status":"publish","type":"post","link":"https:\/\/ihni.uk\/?p=40","title":{"rendered":"House Keeping the SQL Dumps"},"content":{"rendered":"<p>As written in my previous post, the backups had became unwieldy and needed to be archived.<\/p>\n<p>So i added another script to the CronTab to run at 00:01 on the 1st of every month.<\/p>\n<p>I had wanted to do a bit of math to make it see what jobs were created last month and go from there, but that wasn&#8217;t so easy.<\/p>\n<p>Using the <i>find<\/i>\u00a0command i used any thing greater than 31 days as a catch all and hoped for the best&#8230;<!--more--><\/p>\n<blockquote><p><em>#!\/bin\/sh<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><em># House Keeping, archive files over 31 days old.<\/em><\/p>\n<p><em># Runs at 00:01 on the 1st of Every Month via a CronTab<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><em>find \/bkp\/*.tar.gz -mtime +31 -exec 7z a \/bkp\/archive\/&#8221;$(date &#8220;+%B-%Y&#8221; -d &#8216;last month&#8217;)&#8221;.7z {} \\;<\/em><\/p>\n<p><em>find \/bkp\/*.tar.gz -mtime +31 -exec rm {} \\;<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><em>printf &#8220;Monthly Archive Complete for &#8220;&#8221;$(date &#8220;+%B-%Y&#8221; -d &#8216;last month&#8217;)&#8221;&#8221;%s\\n&#8221; &gt;&gt; \/bkp\/logs\/BackupLog.log<\/em><\/p>\n<p><em>printf &#8220;==============================%s\\n&#8221; &gt;&gt; \/bkp\/logs\/BackupLog.log<\/em><\/p><\/blockquote>\n<p>Once again, a bit unwieldy, but it gets the job done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As written in my previous post, the backups had became unwieldy and needed to be&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,12],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-scripts","category-shell-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}