{"id":77,"date":"2013-11-20T17:26:27","date_gmt":"2013-11-20T17:26:27","guid":{"rendered":"http:\/\/wphost.spider-e.com\/?p=77"},"modified":"2013-11-20T17:35:55","modified_gmt":"2013-11-20T17:35:55","slug":"backing-up-my-bugzilla-database","status":"publish","type":"post","link":"https:\/\/wphost.spider-e.com\/?p=77","title":{"rendered":"Backing up my BugZilla database"},"content":{"rendered":"<p>Now that I have bugzilla set up, my clients are starting to use it. It&#8217;s a very useful tool for logging bugs, feature requests and test results. The clients get kept up to date on what I&#8217;m doing, and I don&#8217;t have to remember every thing as it is all kept in the database.<\/p>\n<p>That means that the database has to be protected from loss or damage by taking regular backups.<\/p>\n<p><!--more-->The bugzilla installation on my system uses MySql as the database engine, so I can take a backup of the entire bugzilla database by using the mysqldump command like this:<\/p>\n<pre>\/usr\/local\/mysql\/bin\/mysqldump --user=bugzilla --password=******* bugzilla &gt;backup.sql<\/pre>\n<p>That will create a human readable backup of the entire bugzilla database in the current directory.<br \/>\nTo save space I can pipe the output through gzip to create a compressed output, like this:<\/p>\n<pre>\/usr\/local\/mysql\/bin\/mysqldump --user=bugzilla --password=******* bugzilla | gzip &gt;backup.sql<\/pre>\n<p>I can give the file a more useful location, \u00a0by specifying an explicit path for the output file, and while I&#8217;m at it I can format the file name to include the date on which it was created like this:<\/p>\n<pre>\/usr\/local\/mysql\/bin\/mysqldump --user=bugzilla --password=****** bugzilla | gzip &gt;\/Users\/bz\/backups\/bugs_backup_`date +\\%Y-\\%m-\\%d`.sql.gz<\/pre>\n<p>So now I have a useful command that backs up the entire bugzilla database to a compressed file in a specific location, with a filename that includes the date of the backup. The output filename looks like this:<\/p>\n<pre>bugs_backup_2013-11-20.sql.gz<\/pre>\n<p>So, now to get the command to run automatically at midnight every night, I edit the root user&#8217;s cron tab file by using: (* See note below about &#8216;su&#8217;)<\/p>\n<pre>su\r\ncrontab -e<\/pre>\n<p>and append this (all on one line) to the file:<\/p>\n<pre>0 0 * * * \/usr\/local\/mysql\/bin\/mysqldump --user=bugzilla --password=****** bugzilla | gzip &gt;\/Users\/bz\/backups\/bugs_backup_`date +\\%Y-\\%m-\\%d`.sql.gz<\/pre>\n<p>Now my bugzilla database gets backed up every day at midnight.<\/p>\n<p>Simples!<\/p>\n<p>*NOTE. You must use &#8216;su&#8217; instead of &#8216;sudo&#8217; to edit the crontab, as you need to be editing the root user&#8217;s crontab file, not your normal user&#8217;s file. On most Mac machines the root user is not enabled by default, so see my other post &#8216;<a title=\"Setting up the root user in Mac OS X\" href=\"http:\/\/wphost.spider-e.com\/?p=81\">Setting the root user password on Mac OS X<\/a>&#8216;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that I have bugzilla set up, my clients are starting to use it. It&#8217;s a very useful tool for logging bugs, feature requests and test results. The clients get kept up to date on what I&#8217;m doing, and I don&#8217;t have to remember every thing as it is all kept in the database. That [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,3],"tags":[37,45,11,41,44,43],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-mac","category-software","tag-bugzilla","tag-cron","tag-mac-2","tag-mysql","tag-osz","tag-unix"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p42WEU-1f","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=77"}],"version-history":[{"count":4,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=\/wp\/v2\/posts\/77\/revisions\/83"}],"wp:attachment":[{"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wphost.spider-e.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}