{"id":779,"date":"2009-10-07T19:38:59","date_gmt":"2009-10-08T01:38:59","guid":{"rendered":"http:\/\/gregsowell.com\/?p=779"},"modified":"2009-10-15T10:04:18","modified_gmt":"2009-10-15T16:04:18","slug":"cacti-video-tutorial-%e2%80%93-backups","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=779","title":{"rendered":"Cacti Video Tutorial \u2013 Backups"},"content":{"rendered":"<p>CactiEZ by default runs a backup script nightly. It dumps these files into a folder. All we have to do is configure our CactiEZ box to send those files elsewhere.<\/p>\n<p>Backup location is \/var\/www\/backup.<\/p>\n<p>The backup script itself is \/var\/www\/backup.sh. I modify the backup script as below:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">#\/bin\/bash\r\ncd \/var\/www\/\r\n# Remove old backups\r\nfind \/var\/www\/backups\/* -mtime +5 -exec rm -fr {} \\; &gt; \/dev\/null 2&gt;&amp;1\r\n\r\n# Remove old RRAs (usually means the datasource is deleted)\r\nfind \/var\/www\/html\/rra\/* -mtime +2 -exec rm -fr {} \\; &gt; \/dev\/null 2&gt;&amp;1\r\n\r\n# Create the filename for the backup\r\neval `date &quot;+day=%d; month=%m; year=%Y&quot;`\r\nINSTFIL=&quot;cacti-backup-$year-$month-$day.tar.gz&quot;\r\n\t\r\n# Dump the MySQL Database\r\nmysqldump -uroot --opt cacti&gt; html\/cacti-backup.sql\r\nmysqldump -uroot --ignore-table=syslog.syslog --ignore-table=syslog.syslog_incoming --opt syslog&gt; html\/syslog-backup.sql\r\n\r\ncp \/var\/www\/backup.sh \/var\/www\/html\/backup.sh\r\ncp \/etc\/sysconfig\/iptables \/var\/www\/html\/iptables\r\ncp \/etc\/sysconfig\/network \/var\/www\/html\/network\r\ncp \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \/var\/www\/html\/ifcfg-eth0\r\n\r\n# Gzip the whole folder\r\ntar -Pcpzf backups\/$INSTFIL html\/*\r\n\r\n# Remove the SQL Dump\r\n\r\nrm -f html\/cacti-backup.sql\r\nrm -f html\/syslog-backup.sql\r\nrm -f html\/backup.sh\r\nrm -f html\/iptables\r\nrm -f html\/network\r\nrm -f html\/ifcfg-eth0<\/code><\/pre>\n<p>The above script adds:<br \/>\n\u2013 backup of the script itself<br \/>\n\u2013 modifies the syslog database backup so that it only gets our alerts and removals<br \/>\n\u2013 backs up the iptables rules<br \/>\n\u2013 backs up the eth0 interface configuration<\/p>\n<p>Now for the video tutorial, click the link below!<\/p>\n<p><!--more--><br \/>\n<center><OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" WIDTH=\"863\" HEIGHT=\"483\" CODEBASE=\"http:\/\/active.macromedia.com\/flash5\/cabs\/swflash.cab#version=7,0,0,0\"><br \/>\n<PARAM NAME=movie VALUE=\"\/wink\/cactibackup\/cactibackup.swf\"><br \/>\n<PARAM NAME=play VALUE=true><br \/>\n<PARAM NAME=loop VALUE=false><\/p>\n<p><PARAM NAME=quality VALUE=low><br \/>\n<EMBED SRC=\"\/wink\/cactibackup\/cactibackup.swf\" WIDTH=863 HEIGHT=483 quality=low loop=false TYPE=\"application\/x-shockwave-flash\" PLUGINSPAGE=\"http:\/\/www.macromedia.com\/shockwave\/download\/index.cgi?P1_Prod_Version=ShockwaveFlash\"><br \/>\n<\/EMBED><br \/>\n<\/OBJECT><\/center><br \/>\n<SCRIPT src='\/wink\/cactibackup\/cactibackup.js'><\/script><\/p>\n<p>When you need to actually restore your configuration&#8230;what do you do?<br \/>\nInsert your CactiEZ cd and reinstall, if your machine completely died, or you are migrating to a new machine.<br \/>\nThen, copy and paste the backup files over the top of the old files, without overwriting. You will obviously want to overwrite the iptables files and such.<br \/>\nReimport the SQL files:<br \/>\n<!--DEVFMTCODE--><\/p>\n<pre title=\"Text\">\r\n<div>\r\n<ol>\r\n\t<li>mysql cacti < cacti-backup.sql<\/li>\r\n\t<li>mysql syslog < syslog-backup.sql<\/li>\r\n<\/ol>\r\n<\/div><\/pre>\n<p><!--END_DEVFMTCODE--> <\/p>\n<p>Let me know what you guys think, I need the feedback.<br \/>\n<!--END_DEVFMTCODE--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CactiEZ by default runs a backup script nightly. It dumps these files into a folder. All we have to do is configure our CactiEZ\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,10,21],"tags":[],"class_list":["post-779","post","type-post","status-publish","format-standard","hentry","category-cacti","category-cacti-tutorials","category-cacti-video-tutorial"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=779"}],"version-history":[{"count":4,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions"}],"predecessor-version":[{"id":874,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions\/874"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}