{"id":1193,"date":"2016-07-03T09:32:07","date_gmt":"2016-07-03T09:32:07","guid":{"rendered":"http:\/\/www.testingdocs.com\/questions\/?p=1193"},"modified":"2021-11-18T08:50:39","modified_gmt":"2021-11-18T08:50:39","slug":"how-to-setup-cron-for-testlink-db-backup","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-setup-cron-for-testlink-db-backup\/","title":{"rendered":"How to setup cron for TestLink DB backup?"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>We can set up a backup script for TestLink DB using mysqldump utility and drop an entry in crontab to automatically schedule the backup.<\/p>\n<h3><strong>Example backup script:<\/strong><\/h3>\n<p>The script does a backup with mysqldump utility, Maintains a 7 days backup, and deletes older files. Please feel free to increase the number. The mysqldump utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. It dumps one or more MySQL databases for backup or transfers to another SQL server.<\/p>\n<h3>Script Code<\/h3>\n<p>Below is the sample backup script:<\/p>\n<pre>cd \/opt\/lampstack\/mysql\/bin\r\n\r\n .\/mysqldump -u root -p testlink &gt; \r\n\/opt\/lampstack\/TestLinkBackup\/testlink_backup`date +\"%d%m%y\"`.sql\r\n\r\n  .\/mysqldump -u root -p testlink &gt; \r\n\/opt\/lampstack\/TestLinkBackup\/testlink_backup`date +\"%d%m%y\"`.dump\r\n\r\n  find \/opt\/lampstack\/TestLinkBackup\/ -type f -mtime +7 | xargs rm -f\r\n\r\n\r\n<\/pre>\n<h3><strong>Cron vs Crontab<\/strong><\/h3>\n<p>Cron is a daemon that runs at the times of system boot from \/etc\/init.d scripts. If needed it can be stopped\/started\/restart using <strong>init<\/strong> script or with command service <strong>crond<\/strong> start.<\/p>\n<p>Crontab ( cron table ) is a file that contains the schedule of cron entries to be run and at specified times. File location varies on different distributions.<\/p>\n<h3><strong>Steps to setup cron:<\/strong><\/h3>\n<p>Create a folder and Copy the backup\u00a0<strong> .sh<\/strong> file<\/p>\n<p>Give execute permissions to the specified user where the cron runs.<\/p>\n<p>Add it to the crontab to execute it daily.<\/p>\n<p>Example:<\/p>\n<p>$&gt; crontab -e<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21468\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu.png\" alt=\"crontab ubuntu testlink\" width=\"1920\" height=\"1080\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu-1024x576.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/crontab-ubuntu-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;- minute (0 &#8211; 59)<br \/>\n| +&#8212;&#8212;&#8212;&#8212;- hour (0 &#8211; 23)<br \/>\n| | +&#8212;&#8212;&#8212;- day of month (0 &#8211; 30)<br \/>\n| | | +&#8212;&#8212;- month (1 &#8211; 12)<br \/>\n| | | | +&#8212;- day of week (0 &#8211; 6) (Sunday=0 or 7)<br \/>\n| | | | |<\/p>\n<p>* * * * * command to be executed<\/p>\n<p>&nbsp;<\/p>\n<p>0 12 * * * .\/&lt;path&gt;\/TestlinkBackup.sh<\/p>\n<p>For example : the above command does a backup every day at 12.00 am.<\/p>\n<p>* Note<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>you will find &#8216;cron.hourly&#8217;, &#8216;cron.daily&#8217;, &#8216;cron.weekly&#8217; and &#8216;cron.monthly&#8217; files in \/etc\/<\/p>\n<p>Check that if &#8220;crond&#8221; daemon is running.<\/p>\n<p>$&gt; service crond status<\/p>\n<p>If it is not running type the following two command to start crond:<\/p>\n<p>$&gt; service crond start<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-1193\" data-postid=\"1193\" class=\"themify_builder_content themify_builder_content-1193 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Introduction We can set up a backup script for TestLink DB using mysqldump utility and drop an entry in crontab to automatically schedule the backup. Example backup script: The script does a backup with mysqldump utility, Maintains a 7 days backup, and deletes older files. Please feel free to increase the number. The mysqldump utility [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[212],"class_list":["post-1193","post","type-post","status-publish","format-standard","hentry","category-testlink","tag-testlink","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1193"}],"version-history":[{"count":6,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1193\/revisions"}],"predecessor-version":[{"id":21470,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1193\/revisions\/21470"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}