{"id":3722,"date":"2018-10-12T07:20:43","date_gmt":"2018-10-12T07:20:43","guid":{"rendered":"https:\/\/dbtut.com\/?p=3722"},"modified":"2020-05-31T08:53:32","modified_gmt":"2020-05-31T08:53:32","slug":"bash-script-for-online-db-backup-db2","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/","title":{"rendered":"DB2 Online DB backup Script"},"content":{"rendered":"<p>Following script is useful when you have multiple databases on single instance.<\/p>\n<p>When you need to provide your operation team to take backup of <strong>DB1<\/strong> not the other databases like <em>DB2, DB3<\/em>, following script is helpful to accomplish you task.<\/p>\n<p>Simply add the script in you menu and let them initiate backup what you instructed them.<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/bash\n\nclear\necho \"======================================\"\necho\necho \"ONLINE DB Backup Script\"\necho\necho \"======================================\"\n\necho\necho \"List of database\"\necho\ndb2 list db directory |grep \"Database name\"\necho\necho \"Type database name\"\nread dbname\necho \"Enter COB date For which You are going to Execute(e.g:DDMMYY)\"\nread cobdate\necho \"Type of Application Backup (Type \"Before\" or \"After\" Backup If more then One COB will be executed on same day type Before1 or After1\"\nread bkup\ncb=\"$dbname\"_\"$bkup\"_\"$cobdate\"_COB\nmkdir -p \/backup\/$cb\necho $cb\n\ndb2 connect to $dbname\ndate\n\ndate &gt; backup_rpt.txt\n\ndb2 backup database $dbname online to \/backup\/$cb compress &gt;&gt; backup_rpt.txt\ndate\n\ndate &gt;&gt; backup_rpt.txt\ndu -ms \/backup\/$cb &gt;&gt; backup_rpt.txt\necho \"Current DB Backup Size\"\ndu -ms \/backup\/$cb\necho \"Your $dbname-$bkup-$cobdate DB Backup is Created\"\n\nmail -s \"$dbname-$bkup-$cobdate DB ONLINE BACKUP\" &lt; backup_rpt.txt<\/pre>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_3722\" class=\"pvc_stats all  \" data-element-id=\"3722\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Following script is useful when you have multiple databases on single instance. When you need to provide your operation team to take backup of DB1 not the other databases like DB2, DB3, following script is helpful to accomplish you task. Simply add the script in you menu and let them initiate backup what you instructed &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_3722\" class=\"pvc_stats all  \" data-element-id=\"3722\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":391,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1305],"tags":[1523],"class_list":["post-3722","post","type-post","status-publish","format-standard","","category-db2","tag-online-backup-script"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>DB2 Online DB backup Script - Database Tutorials<\/title>\n<meta name=\"description\" content=\"Bash Script For Online DB backup DB2\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DB2 Online DB backup Script - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"Bash Script For Online DB backup DB2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-12T07:20:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-31T08:53:32+00:00\" \/>\n<meta name=\"author\" content=\"Syed Naveed Raza\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NaveedSupport\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Syed Naveed Raza\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\"},\"author\":{\"name\":\"Syed Naveed Raza\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/5983577144c7e7351a238fe559775fe2\"},\"headline\":\"DB2 Online DB backup Script\",\"datePublished\":\"2018-10-12T07:20:43+00:00\",\"dateModified\":\"2020-05-31T08:53:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\"},\"wordCount\":64,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"keywords\":[\"online backup script\"],\"articleSection\":[\"DB2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\",\"name\":\"DB2 Online DB backup Script - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"datePublished\":\"2018-10-12T07:20:43+00:00\",\"dateModified\":\"2020-05-31T08:53:32+00:00\",\"description\":\"Bash Script For Online DB backup DB2\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DB2 Online DB backup Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/5983577144c7e7351a238fe559775fe2\",\"name\":\"Syed Naveed Raza\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9207baa13f7d94cf3076735adba833f4065acf91101c4904ff5057ee86dc7d2c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9207baa13f7d94cf3076735adba833f4065acf91101c4904ff5057ee86dc7d2c?s=96&d=mm&r=g\",\"caption\":\"Syed Naveed Raza\"},\"description\":\"I have experience to manage DB2 &amp; Oracle plus 3 year of experience as Temenos T24 Core Administrator on AIX &amp; IBM Integration Bus 10.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/syed-naveed-raza-453aa835\/\",\"https:\/\/x.com\/NaveedSupport\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/syednaveedraza\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DB2 Online DB backup Script - Database Tutorials","description":"Bash Script For Online DB backup DB2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/","og_locale":"en_US","og_type":"article","og_title":"DB2 Online DB backup Script - Database Tutorials","og_description":"Bash Script For Online DB backup DB2","og_url":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/","og_site_name":"Database Tutorials","article_published_time":"2018-10-12T07:20:43+00:00","article_modified_time":"2020-05-31T08:53:32+00:00","author":"Syed Naveed Raza","twitter_card":"summary_large_image","twitter_creator":"@NaveedSupport","twitter_misc":{"Written by":"Syed Naveed Raza","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/"},"author":{"name":"Syed Naveed Raza","@id":"https:\/\/dbtut.com\/#\/schema\/person\/5983577144c7e7351a238fe559775fe2"},"headline":"DB2 Online DB backup Script","datePublished":"2018-10-12T07:20:43+00:00","dateModified":"2020-05-31T08:53:32+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/"},"wordCount":64,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"keywords":["online backup script"],"articleSection":["DB2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/","url":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/","name":"DB2 Online DB backup Script - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"datePublished":"2018-10-12T07:20:43+00:00","dateModified":"2020-05-31T08:53:32+00:00","description":"Bash Script For Online DB backup DB2","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/10\/12\/bash-script-for-online-db-backup-db2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"DB2 Online DB backup Script"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/5983577144c7e7351a238fe559775fe2","name":"Syed Naveed Raza","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9207baa13f7d94cf3076735adba833f4065acf91101c4904ff5057ee86dc7d2c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9207baa13f7d94cf3076735adba833f4065acf91101c4904ff5057ee86dc7d2c?s=96&d=mm&r=g","caption":"Syed Naveed Raza"},"description":"I have experience to manage DB2 &amp; Oracle plus 3 year of experience as Temenos T24 Core Administrator on AIX &amp; IBM Integration Bus 10.","sameAs":["https:\/\/www.linkedin.com\/in\/syed-naveed-raza-453aa835\/","https:\/\/x.com\/NaveedSupport"],"url":"https:\/\/dbtut.com\/index.php\/author\/syednaveedraza\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/3722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/391"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=3722"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/3722\/revisions"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=3722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=3722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=3722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}