{"id":322,"date":"2009-08-24T22:54:21","date_gmt":"2009-08-24T22:54:21","guid":{"rendered":"http:\/\/blog.cyberwizzard.nl\/?p=322"},"modified":"2016-03-20T14:08:45","modified_gmt":"2016-03-20T13:08:45","slug":"kill-all-waiting-backup-jobs-in-bacula","status":"publish","type":"post","link":"https:\/\/blog.cyberwizzard.nl\/?p=322","title":{"rendered":"Kill all waiting backup jobs in Bacula"},"content":{"rendered":"<p>If you are a Bacula user, you most likely had the problem of a Director clogging up on one or more jobs getting stuck while others keep piling up. With the new directives for managing duplicate jobs, this should not happen anymore but last night I found out that 2 of my backup servers managed to dead-lock.<\/p>\n<p>The resulting job queue was over 300 jobs long and restarting the Director did not seem to help. So I threw a little shell script together to use bconsole to cancel all jobs in a waiting state.<\/p>\n<p>Us usual, use on your own risk, I only tested it on my servers and it worked fine\u2026<\/p>\n<pre class=\"code hl hl-bash\"><span class=\"co0\">#!\/bin\/bash<\/span>\n<span class=\"re2\">jobIds<\/span>=<span class=\"sy0\">`<\/span><span class=\"kw3\">echo<\/span> <span class=\"st_h\">'status dir running'<\/span> <span class=\"sy0\">|<\/span> bconsole <span class=\"sy0\">|<\/span> <span class=\"kw2\">fgrep<\/span> <span class=\"st_h\">'is waiting'<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">awk<\/span> <span class=\"st_h\">'{print $1}'<\/span><span class=\"sy0\">`<\/span>\n<span class=\"kw1\">for<\/span> i <span class=\"kw1\">in<\/span> <span class=\"re1\">$jobIds<\/span>\n<span class=\"kw1\">do<\/span>\n&nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#91;<\/span> <span class=\"re5\">-z<\/span> <span class=\"sy0\">`<\/span><span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$i<\/span>&quot;<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> <span class=\"st_h\">'^[0-9]\\+$'<\/span><span class=\"sy0\">`<\/span> <span class=\"br0\">&#93;<\/span>\n&nbsp; <span class=\"kw1\">then<\/span>\n&nbsp; &nbsp; <span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Error: job ID <span class=\"es2\">$i<\/span> is not a number!&quot;<\/span>\n&nbsp; <span class=\"kw1\">else<\/span>\n&nbsp; &nbsp; <span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Killing waiting Bacula job <span class=\"es2\">$i<\/span>&quot;<\/span>\n&nbsp; &nbsp; <span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;cancel jobid=<span class=\"es2\">$i<\/span>&quot;<\/span> <span class=\"sy0\">|<\/span> bconsole\n&nbsp; <span class=\"kw1\">fi<\/span>\n<span class=\"kw1\">done<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are a Bacula user, you most likely had the problem of a Director clogging up on one or more jobs getting stuck while others keep piling up. With the new directives for managing duplicate jobs, this should not happen anymore but last night I found out that 2 of my backup servers managed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[375,368,326],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-gentoo-linux","tag-backup","tag-bacula","tag-gentoo"],"views":3286,"_links":{"self":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322"}],"version-history":[{"count":3,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":575,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions\/575"}],"wp:attachment":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}