{"id":4371,"date":"2019-11-21T05:44:39","date_gmt":"2019-11-21T05:44:39","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4371"},"modified":"2019-11-21T05:45:12","modified_gmt":"2019-11-21T05:45:12","slug":"how-to-backup-and-restore-a-sql-database","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/how-to-backup-and-restore-a-sql-database","title":{"rendered":"How to backup and restore a SQL Database"},"content":{"rendered":"<p>If the SQL databases are in simple recovery<\/p><p>[pastacode lang=&#8221;sql&#8221; manual=&#8221;Backup%0A%0AALTER%20DATABASE%20dbname%0A%0ASET%20READ_ONLY%3B%0A%0AGO%0A%20%0A%0ABackup%20database%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0A%20%0ARestore%0A%0A%0ARestore%20database%20dbname%0A%0Afrom%20disk%20%3D%20%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0Awith%20recovery%2C%20replace%0A%0A%20%0A%0AALTER%20DATABASE%20dbname%0A%0ASET%20MULTI_USER%3B%0A%0AGO&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p><p>If the databases are in full recovery model<\/p><p>[pastacode lang=&#8221;sql&#8221; manual=&#8221;Backup%0A%0ABackup%20database%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0ABackup%20log%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.trn&#8217;%0A%0Awith%20norecovery%0A%0A%20%0ARestore%0A%0A%20%0ARestore%20database%20dbname%0A%0Afrom%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0Awith%20norecovery%2C%20replace%0A%0ARestore%20log%20test2%0A%0Afrom%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.trn&#8217;%0A%0Awith%20recovery%0A%20&#8243; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>","protected":false},"excerpt":{"rendered":"<p>If the SQL databases are in simple recovery[pastacode lang=&#8221;sql&#8221; manual=&#8221;Backup%0A%0AALTER%20DATABASE%20dbname%0A%0ASET%20READ_ONLY%3B%0A%0AGO%0A%20%0A%0ABackup%20database%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0A%20%0ARestore%0A%0A%0ARestore%20database%20dbname%0A%0Afrom%20disk%20%3D%20%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0Awith%20recovery%2C%20replace%0A%0A%20%0A%0AALTER%20DATABASE%20dbname%0A%0ASET%20MULTI_USER%3B%0A%0AGO&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]If the databases are in full recovery model[pastacode lang=&#8221;sql&#8221; manual=&#8221;Backup%0A%0ABackup%20database%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0ABackup%20log%20dbname%0A%0Ato%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.trn&#8217;%0A%0Awith%20norecovery%0A%0A%20%0ARestore%0A%0A%20%0ARestore%20database%20dbname%0A%0Afrom%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.bak&#8217;%0A%0Awith%20norecovery%2C%20replace%0A%0ARestore%20log%20test2%0A%0Afrom%20disk%20%3D%20&#8217;C%3A%5C&#8230;%5Cdbname.trn&#8217;%0A%0Awith%20recovery%0A%20&#8243; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[736,1106,591],"class_list":["post-4371","post","type-post","status-publish","format-standard","hentry","category-research","tag-backup","tag-restore","tag-sql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4371"}],"version-history":[{"count":2,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4371\/revisions"}],"predecessor-version":[{"id":4373,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4371\/revisions\/4373"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}