-
Notifications
You must be signed in to change notification settings - Fork 12
/
Backup-DbaDatabase.html
1704 lines (1674 loc) · 52.7 KB
/
Backup-DbaDatabase.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>dbatools docs | Backup-DbaDatabase</title>
<link rel="icon" href="https://dbatools.io/wp-content/uploads/2016/05/dbatools.png" sizes="32x32">
<link rel="icon" href="https://dbatools.io/wp-content/uploads/2016/05/dbatools.png" sizes="192x192">
<link rel="apple-touch-icon-precomposed" href="https://dbatools.io/wp-content/uploads/2016/05/dbatools.png">
<meta name="msapplication-TileImage" content="https://dbatools.io/wp-content/uploads/2016/05/dbatools.png">
<link title="Search" rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml">
<meta name="keywords" content="dbatools, ,powershell,sql server,devops,json">
<meta name="subtitle" content="Docs for Backup-DbaDatabase">
<meta property="og:type" content="article" />
<meta property="og:title" content="dbatools docs: Backup-DbaDatabase" />
<meta property="og:url" content="https://docs.dbatools.io/Backup-DbaDatabase.html" />
<meta property="og:description" content="dbatools docs for Backup-DbaDatabase" />
<meta property="og:site_name" content="docs.dbatools.io" />
<meta property="og:locale" content="en_US" />
<meta name="twitter:text:title" content="dbatools docs: Backup-DbaDatabase" />
<meta name="twitter:image" content="https://docs.dbatools.io/assets/thumbs/Backup-DbaDatabase.png">
<meta name="twitter:card" content="summary_large_image">
<meta name=twitter:creator content="@psdbatools">
<meta name=twitter:title content="dbatools docs: Backup-DbaDatabase">
<meta property="twitter:site" content="@psdbatools" />
<meta property="og:image" content="https://docs.dbatools.io/assets/thumbs/Backup-DbaDatabase.png">
<link rel=canonical href="https://docs.dbatools.io/Backup-DbaDatabase.html" />
<link rel=alternate type=application/json
href=https://raw.githubusercontent.com/dataplat/dbatools/master/bin/dbatools-index.json
title="dbatools documentation">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" type="text/css"
href="//cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic-bootstrap.min.css">
<link rel="stylesheet" type="text/css"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
<link rel="stylesheet" href="assets/css/layout.css">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-80639740-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-80639740-2');
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.scrollto/2.1.2/jquery.scrollTo.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/autolinker/1.7.1/Autolinker.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jqcloud.min.js"
integrity="sha256-+krhsKJpvd3AZYVGHcwyCUGO01uNdGSTvqR7Apcy30E=" crossorigin="anonymous"></script>
<script type="text/javascript" language="javascript">
function register_dbatools_hljs(dbatoolscommands) {
hljs.registerLanguage("powershell", function (e) {
var t = {
b: "`[\\s\\S]",
r: 0
},
o = {
cN: "variable",
v: [{
b: /\$[\w\d][\w\d_:]*/
}]
},
r = {
cN: "literal",
b: /\$(null|true|false)\b/
},
n = {
cN: "string",
v: [{
b: /"/,
e: /"/
}, {
b: /@"/,
e: /^"@/
}],
c: [t, o, {
cN: "variable",
b: /\$[A-z]/,
e: /[^A-z]/
}]
},
a = {
cN: "string",
v: [{
b: /'/,
e: /'/
}, {
b: /@'/,
e: /^'@/
}]
},
i = {
cN: "doctag",
v: [{
b: /\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/
}, {
b: /\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/
}]
},
s = e.inherit(e.C(null, null), {
v: [{
b: /#/,
e: /$/
}, {
b: /<#/,
e: /#>/
}],
c: [i]
});
return {
aliases: ["ps"],
l: /-?[A-z\.\-]+/,
cI: !0,
k: {
keyword: "if else foreach return function do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch",
built_in: dbatoolscommands + " Add-Computer Add-Content Add-History Add-JobTrigger Add-Member Add-PSSnapin Add-Type Checkpoint-Computer Clear-Content Clear-EventLog Clear-History Clear-Host Clear-Item Clear-ItemProperty Clear-Variable Compare-Object Complete-Transaction Connect-PSSession Connect-WSMan Convert-Path ConvertFrom-Csv ConvertFrom-Json ConvertFrom-SecureString ConvertFrom-StringData ConvertTo-Csv ConvertTo-Html ConvertTo-Json ConvertTo-SecureString ConvertTo-Xml Copy-Item Copy-ItemProperty Debug-Process Disable-ComputerRestore Disable-JobTrigger Disable-PSBreakpoint Disable-PSRemoting Disable-PSSessionConfiguration Disable-WSManCredSSP Disconnect-PSSession Disconnect-WSMan Disable-ScheduledJob Enable-ComputerRestore Enable-JobTrigger Enable-PSBreakpoint Enable-PSRemoting Enable-PSSessionConfiguration Enable-ScheduledJob Enable-WSManCredSSP Enter-PSSession Exit-PSSession Export-Alias Export-Clixml Export-Console Export-Counter Export-Csv Export-FormatData Export-ModuleMember Export-PSSession ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-ComputerRestorePoint Get-Content Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-Date Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy Get-FormatData Get-Host Get-HotFix Get-Help Get-History Get-IseSnippet Get-Item Get-ItemProperty Get-Job Get-JobTrigger Get-Location Get-Member Get-Module Get-PfxCertificate Get-Process Get-PSBreakpoint Get-PSCallStack Get-PSDrive Get-PSProvider Get-PSSession Get-PSSessionConfiguration Get-PSSnapin Get-Random Get-ScheduledJob Get-ScheduledJobOption Get-Service Get-TraceSource Get-Transaction Get-TypeData Get-UICulture Get-Unique Get-Variable Get-Verb Get-WinEvent Get-WmiObject Get-WSManCredSSP Get-WSManInstance Group-Object Import-Alias Import-Clixml Import-Counter Import-Csv Import-IseSnippet Import-LocalizedData Import-PSSession Import-Module Invoke-AsWorkflow Invoke-Command Invoke-Expression Invoke-History Invoke-Item Invoke-RestMethod Invoke-WebRequest Invoke-WmiMethod Invoke-WSManAction Join-Path Limit-EventLog Measure-Command Measure-Object Move-Item Move-ItemProperty New-Alias New-Event New-EventLog New-IseSnippet New-Item New-ItemProperty New-JobTrigger New-Object New-Module New-ModuleManifest New-PSDrive New-PSSession New-PSSessionConfigurationFile New-PSSessionOption New-PSTransportOption New-PSWorkflowExecutionOption New-PSWorkflowSession New-ScheduledJobOption New-Service New-TimeSpan New-Variable New-WebServiceProxy New-WinEvent New-WSManInstance New-WSManSessionOption Out-Default Out-File Out-GridView Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Receive-Job Register-EngineEvent Register-ObjectEvent Register-PSSessionConfiguration Register-ScheduledJob Register-WmiEvent Remove-Computer Remove-Event Remove-EventLog Remove-Item Remove-ItemProperty Remove-Job Remove-JobTrigger Remove-Module Remove-PSBreakpoint Remove-PSDrive Remove-PSSession Remove-PSSnapin Remove-TypeData Remove-Variable Remove-WmiObject Remove-WSManInstance Rename-Computer Rename-Item Rename-ItemProperty Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service Restore-Computer Resume-Job Resume-Service Save-Help Select-Object Select-String Select-Xml Send-MailMessage Set-Acl Set-Alias Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-JobTrigger Set-Location Set-PSBreakpoint Set-PSDebug Set-PSSessionConfiguration Set-ScheduledJob Set-ScheduledJobOption Set-Service Set-StrictMode Set-TraceSource Set-Variable Set-WmiInstance Set-WSManInstance Set-WSManQuickConfig Show-Command Show-ControlPanelItem Show-EventLog Sort-Object Split-Path Start-Job Start-Process Start-Service Start-Sleep Start-Transaction Start-Transcript Stop-Computer Stop-Job Stop-Process Stop-Service Stop-Transcript Suspend-Job Suspend-Service Tee-Object Test-ComputerSecureChannel Test-Connection Test-ModuleManifest Test-Path Test-PSSessionConfigurationFile Trace-Command Unblock-File Undo-Transaction Unregister-Event Unregister-PSSessionConfiguration Unregister-ScheduledJob Update-FormatData Update-Help Update-List Update-TypeData Use-Transaction Wait-Event Wait-Job Wait-Process Where-Object Write-Debug Write-Error Write-EventLog Write-Host Write-Output Write-Progress Write-Verbose Write-Warning Add-MDTPersistentDrive Disable-MDTMonitorService Enable-MDTMonitorService Get-MDTDeploymentShareStatistics Get-MDTMonitorData Get-MDTOperatingSystemCatalog Get-MDTPersistentDrive Import-MDTApplication Import-MDTDriver Import-MDTOperatingSystem Import-MDTPackage Import-MDTTaskSequence New-MDTDatabase Remove-MDTMonitorData Remove-MDTPersistentDrive Restore-MDTPersistentDrive Set-MDTMonitorData Test-MDTDeploymentShare Test-MDTMonitorData Update-MDTDatabaseSchema Update-MDTDeploymentShare Update-MDTLinkedDS Update-MDTMedia Update-MDTMedia Add-VamtProductKey Export-VamtData Find-VamtManagedMachine Get-VamtConfirmationId Get-VamtProduct Get-VamtProductKey Import-VamtData Initialize-VamtData Install-VamtConfirmationId Install-VamtProductActivation Install-VamtProductKey Update-VamtProduct",
nomarkup: "-ne -eq -lt -gt -ge -le -not -like -notlike -match -notmatch -contains -notcontains -in -notin -replace"
},
c: [t, e.NM, n, a, r, o, s]
}
});
}
$(document).ready(function () {
function render_doc(doc_to_render, examples_mode) {
$("#rendered h5").each(function (i, el) {
if ($(el).text().startsWith('-')) {
$(el).addClass('param')
}
})
$('#rendered table').addClass('table table-sm table-hover')
if (examples_mode == 'new') {
$('#rendered code').addClass('powershell')
}
$('#rendered code').each(function (i, block) {
hljs.highlightBlock(block);
})
var authorcontent = $("td:contains('Author')").next('td').addClass('dbatools_author').text()
$("#rendered .dbatools_author").html(Autolinker.link(authorcontent, {
className: 'myLink',
mention: 'twitter'
})
)
$("#rendered h2#syntax").next().find('code').addClass('wrapped')
if (ClipboardJS.isSupported()) {
$("#rendered h5[id^='example-']").append('<div class="bd-clipboard"><button class="btn-clipboard" title="Copy to clipboard">Copy</button></div>')
new ClipboardJS('.btn-clipboard', {
text: function (trigger) {
var textlines = $(trigger).parent().parent().next('pre').find('code').text().split('\n')
var copied = []
_.forEach(textlines, function (row) {
copied.push(row.replace(/^PS C:\\> /, "").replace(/^>>/, ""))
})
return _.join(copied, '\n')
}
});
}
//not all code is a block
$("#rendered h3[id*='-parameters']").nextAll().find('code').addClass('hljs-inline')
$('#rendered #description').nextUntil('#rendered #syntax').find('code').addClass('hljs-inline')
}
$('#loader').removeClass('invisible')
var index_url = 'assets/dbatools-index.json'
var external_url = 'assets/external.json'
var values = [];
var options = {
valueNames: ['CommandName', 'Description', 'Alias', 'Examples', 'Params'],
item: '<a class="list-group-item" href="#"><span class="CommandName"></span></a>'
}
cmdlist = new List('cmdlist', options, values);
var indexhelp = ''
var allcmds = $.getJSON(index_url, function (data) {
indexhelp = data
cmdlist.add(data)
var dbacommands = []
var cloudlist = {}
_.forEach(data, function (el) {
dbacommands.push(el.CommandName)
if (_.isArray(el.Tags)) {
_.forEach(el.Tags, function (el) {
if (!_.has(cloudlist, el)) {
cloudlist[el] = 0
}
cloudlist[el] += 1
})
} else if (!_.isUndefined(el.Tags)){
if (!_.has(cloudlist, el.Tags)) {
cloudlist[el.Tags] = 0
}
cloudlist[el.Tags] += 1
}
})
var weightedVals = []
_.forEach(cloudlist, function (value, key) {
weightedVals.push({
text: key,
weight: value,
handlers: {
click: function () { $('#search-ft').val('tag:' + key).trigger('keyup') }
}
})
})
var pixelHeight = window.innerHeight * 0.65;
$('#canvas').css({ 'height': pixelHeight + 'px' });
$('#canvas').jQCloud(weightedVals, {
autoResize: true
});
register_dbatools_hljs(dbacommands.join(' '))
$(window).trigger('hashchange');
})
var options2 = {
valueNames: ['extName', { name: 'extHref', attr: 'href' }],
item: '<div><a class="list-group-item list-group-item-secondary extHref" href="#" _target="_blank"><span class="extName"></span></a></div>'
}
extlist = new List('extlist', options2, [])
$.getJSON(external_url, function (data) {
$('#dbatools_version').text('(v ' + data.version + ')')
_.forEach(data.external_links, function (el) {
extlist.add({ 'extName': el.name, 'extHref': el.href })
})
})
cmdlist.on('searchComplete', function (e) {
if (cmdlist.matchingItems.length === 0) {
var searchString = $('#search-ft').val().trim();
if (searchString.length > 0 && !searchString.startsWith("ft:")) {
if (searchString != "f" && searchString != "ft" && searchString != "ft:") {
$('#search-ft').val("ft:" + searchString)
}
}
}
})
$(document).on('mouseenter', '#cmdlist', function (e) {
$('#search-ft').blur();
})
cmdlist.on('updated', function() {
$('#cmdlist a').each(function(i, el) {
$(el).attr('href', $(el).find('span.CommandName').text())
})
})
$('#cmdlist').on('mouseenter', 'a', function (e) {
$(this).attr('href', $(this).find('span.CommandName').text());
/*
e.preventDefault();
window.location.href = $(this).find('span.CommandName').text()
---
window.location.hash = '#' + $(this).find('span.CommandName').text();
$('#cmdlist').find('a.active').removeClass('active')
$(this).addClass('active')
*/
})
$('#search-ft').bind('change keyup', function () {
var searchString = $(this).val();
if (searchString.trim() == "ft:" || searchString.trim() == "tag:") {
extlist.search();
}
else if (searchString.startsWith("ft:")) {
searchString = searchString.substring(3).trim();
if (cmdlist.filtered) {
cmdlist.filter();
}
cmdlist.search(searchString, ['CommandName', 'Alias', 'Description', 'Synopsis', 'Examples', 'Params']);
} else if (searchString.startsWith("tag:")) {
searchString = searchString.substring(4).trim();
if (cmdlist.searched) {
cmdlist.search();
}
cmdlist.filter(function (item) {
if (_.indexOf(item.values().Tags, searchString) !== -1) {
return true;
} else {
return false;
}
});
} else {
if (cmdlist.filtered) {
cmdlist.filter();
}
cmdlist.search(searchString, ['CommandName', 'Alias']);
}
extlist.search('$$$')
if (_.isEmpty(searchString)) {
extlist.search()
cmdlist.filter()
}
})
$('#clear-search').on('click', function () {
$('#search-ft').val('').trigger('keyup')
})
$(window).on('hashchange', function (e) {
var hash = window.location.hash.substr(1);
var pagename = window.location.pathname.split("/").filter(function (c) { return c.length; }).pop();
if (_.isUndefined(pagename)) {
pagename = ''
} else {
pagename = pagename.split('.')[0];
}
if (hash.length == 0) {
hash = pagename
}
if (hash.length > 0) {
//ends with /
if (_.endsWith(hash, '/')) {
window.location.hash = '#' + hash.slice(0, hash.length - 1)
$(window).trigger('hashchange');
return;
}
//exact match
var topublish = _.findIndex(indexhelp, { 'Name': hash })
if (topublish == -1) {
//lowercase match
var topublish = _.findIndex(indexhelp, function (el) { return _.toLower(el.Name) == _.toLower(hash) })
if (topublish == -1) {
//alias match
var topublish = _.findIndex(indexhelp, { 'Alias': hash })
if (topublish == -1) {
//lowercase alias match
var topublish = _.findIndex(indexhelp, function (el) { return _.toLower(el.Alias) == _.toLower(hash) })
}
if (topublish == -1) {
//multiple aliases, optionally lowercased
var topublish = _.findIndex(indexhelp, function (el) { return _.includes(_.toLower(el.Alias).split(','), _.toLower(hash)) })
}
}
if (topublish !== -1) {
//normalization of URI
window.location.hash = '#' + indexhelp[topublish].CommandName
$(window).trigger('hashchange')
return;
}
}
if (topublish == -1) {
$('#rendered').html(marked.parse('### 404 Function not found \n (while searching for ' + hash + '). Please visit dbatools.io/commands for an updated index of current commands.'));
} else {
var doc_to_render = indexhelp[topublish]
render_doc(doc_to_render, 'new')
$("body").data("doc_to_render", indexhelp[topublish])
if ($("#headscroll").offset().top > 150) {
$(window).scrollTo('#headscroll')
} else {
$(window).scrollTo(0, 800)
}
}
} else {
$('#loader').addClass('invisible')
}
})
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
})
$('#back-to-top').click(function () {
$(window).scrollTo(0, 800)
return false;
})
})
</script>
</head>
<body>
<nav class="navbar navbar-expand-md customnav">
<a href="https://docs.dbatools.io/" class="navbar-brand" rel="home" itemprop="url">
<img width="265" height="64" src="https://dbatools.io/wp-content/uploads/2018/09/dbatools-docs.png"
class="custom-logo" alt="dbatools" itemprop="logo" scale="0">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="oi oi-menu"></span>
</button>
<div class="collapse navbar-collapse flex-grow-1 text-right" id="navbarCollapse">
<ul class="navbar-nav ml-auto flex-nowrap">
<li class="nav-item">
<a class="nav-link" style="color:#293E5D" href="https://dbatools.io/download/">⬇ download</a>
</li>
<li class="nav-item">
<a class="nav-link" style="color:#293E5D" href="https://dbatools.io/commands/">🚀 commands</a>
</li>
<li class="nav-item">
<a class="nav-link" style="color:#293E5D" href="https://dbatools.io/slack">🔍 find us</a>
</li>
<li class="nav-item">
<a class="nav-link" style="color:#293E5D" href="https://dbatools.io/builds">🔢 build ref</a>
</li>
<li class="nav-item">
<a class="nav-link" style="color:#293E5D" href="https://dbatools.io/book">📘 dbatools book</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<hr />
</div>
</div>
<div class="row">
<div class="col-xl-3 col-lg-5 col-md-5 col-sm-12 bd-sidebar">
<div id="relcommands" class="">
<h3>
commands
<small id="dbatools_version" class="text-muted"></small>
</h3>
<p></p>
<div class="form-group row">
<div class="col-lg-12">
<div class="input-group">
<input type="text" class="form-control" id="search-ft"
placeholder="Search ("ft: term" enables fulltext)" autocomplete="off">
<div class="input-group-append">
<div class="input-group-text" id="clear-search">Clear</div>
</div>
</div>
</div>
</div>
<div id="extlist">
<div class="list list-group"></div>
</div>
<div id="cmdlist">
<div class="list list-group"></div>
</div>
</div>
</div>
<div class="col-xl-9 col-lg-7 col-md-7 col-sm-12 bd-content">
<div id="headscroll">
<a id="back-to-top" href="#" class="btn btn-primary btn-lg back-to-top" role="button"
title="Click to return on the top page">^</a>
</div>
<div id="rendered">
<h1 id="backup-dbadatabase">Backup-DbaDatabase</h1>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Author</strong></td>
<td>Stuart Moore (@napalmgram), stuart-moore.com</td>
</tr>
<tr>
<td><strong>Availability</strong></td>
<td>Windows, Linux, macOS</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Want to see the source code for this command? Check out <a href="https://github.com/dataplat/dbatools/blob/master/public/Backup-DbaDatabase.ps1">Backup-DbaDatabase</a> on GitHub.
<br>
Want to see the Bill Of Health for this command? Check out <a href="https://dataplat.github.io/boh#Backup-DbaDatabase">Backup-DbaDatabase</a>.</p>
<h2 id="synopsis">Synopsis</h2>
<p>Backup one or more SQL Server databases from a single SQL Server SqlInstance.</p>
<h2 id="description">Description</h2>
<p>Performs a backup of a specified type of 1 or more databases on a single SQL Server Instance. These backups may be Full, Differential or Transaction log backups.</p>
<h2 id="syntax">Syntax</h2>
<pre><code>Backup-DbaDatabase
[-SqlCredential <PSCredential>]
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-Path <String[]>]
[-FilePath <String>]
[-IncrementPrefix]
[-ReplaceInName]
[-NoAppendDbNameInPath]
[-CopyOnly]
[-Type <String>]
[-CreateFolder]
[-FileCount <Int32>]
[-CompressBackup]
[-Checksum]
[-Verify]
[-MaxTransferSize <Int32>]
[-BlockSize <Int32>]
[-BufferCount <Int32>]
[-AzureBaseUrl <String[]>]
[-AzureCredential <String>]
[-NoRecovery]
[-BuildPath]
[-WithFormat]
[-Initialize]
[-SkipTapeHeader]
[-TimeStampFormat <String>]
[-IgnoreFileChecks]
[-OutputScriptOnly]
[-EncryptionAlgorithm <String>]
[-EncryptionCertificate <String>]
[-Description <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Backup-DbaDatabase -SqlInstance <DbaInstanceParameter>
[-SqlCredential <PSCredential>]
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-Path <String[]>]
[-FilePath <String>]
[-IncrementPrefix]
[-ReplaceInName]
[-NoAppendDbNameInPath]
[-CopyOnly]
[-Type <String>]
[-CreateFolder]
[-FileCount <Int32>]
[-CompressBackup]
[-Checksum]
[-Verify]
[-MaxTransferSize <Int32>]
[-BlockSize <Int32>]
[-BufferCount <Int32>]
[-AzureBaseUrl <String[]>]
[-AzureCredential <String>]
[-NoRecovery]
[-BuildPath]
[-WithFormat]
[-Initialize]
[-SkipTapeHeader]
[-TimeStampFormat <String>]
[-IgnoreFileChecks]
[-OutputScriptOnly]
[-EncryptionAlgorithm <String>]
[-EncryptionCertificate <String>]
[-Description <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Backup-DbaDatabase
[-SqlCredential <PSCredential>]
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-Path <String[]>]
[-FilePath <String>]
[-IncrementPrefix]
[-ReplaceInName]
[-NoAppendDbNameInPath]
[-CopyOnly]
[-Type <String>]
-InputObject <Object[]>
[-CreateFolder]
[-FileCount <Int32>]
[-CompressBackup]
[-Checksum]
[-Verify]
[-MaxTransferSize <Int32>]
[-BlockSize <Int32>]
[-BufferCount <Int32>]
[-AzureBaseUrl <String[]>]
[-AzureCredential <String>]
[-NoRecovery]
[-BuildPath]
[-WithFormat]
[-Initialize]
[-SkipTapeHeader]
[-TimeStampFormat <String>]
[-IgnoreFileChecks]
[-OutputScriptOnly]
[-EncryptionAlgorithm <String>]
[-EncryptionCertificate <String>]
[-Description <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
</code></pre>
<p> </p>
<h2 id="examples">Examples</h2>
<p> </p>
<h5 id="example-1">Example: 1</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Server1 -Database HR, Finance
</code></pre>
<p>This will perform a full database backup on the databases HR and Finance on SQL Server Instance Server1 to Server1 default backup directory.<br></p>
<h5 id="example-2">Example: 2</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance sql2016 -Path C:\temp -Database AdventureWorks2014 -Type Full
</code></pre>
<p>Backs up AdventureWorks2014 to sql2016 C:\temp folder.<br></p>
<h5 id="example-3">Example: 3</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance sql2016 -AzureBaseUrl https://dbatoolsaz.blob.core.windows.net/azbackups/ -AzureCredential dbatoolscred -Type Full -CreateFolder
</code></pre>
<p>Performs a full backup of all databases on the sql2016 instance to their own containers under the <a href="https://dbatoolsaz.blob.core.windows.net/azbackups/">https://dbatoolsaz.blob.core.windows.net/azbackups/</a> container on Azure blob storage using the sql <br>
credential "dbatoolscred" registered on the sql2016 instance.<br></p>
<h5 id="example-4">Example: 4</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance sql2016 -AzureBaseUrl https://dbatoolsaz.blob.core.windows.net/azbackups/ -Type Full
</code></pre>
<p>Performs a full backup of all databases on the sql2016 instance to the <a href="https://dbatoolsaz.blob.core.windows.net/azbackups/">https://dbatoolsaz.blob.core.windows.net/azbackups/</a> container on Azure blob storage using the Shared Access Signature sql <br>
credential "https://dbatoolsaz.blob.core.windows.net/azbackups" registered on the sql2016 instance.<br></p>
<h5 id="example-5">Example: 5</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Server1\Prod -Database db1 -Path \\filestore\backups\servername\instancename\dbname\backuptype -Type Full -ReplaceInName
</code></pre>
<p>Performs a full backup of db1 into the folder \filestore\backups\server1\prod\db1\Full<br></p>
<h5 id="example-6">Example: 6</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Server1\Prod -Path \\filestore\backups\servername\instancename\dbname\backuptype -FilePath dbname-backuptype-timestamp.trn -Type Log -ReplaceInName
</code></pre>
<p>Performs a log backup for every database. For the database db1 this would results in backup files in \filestore\backups\server1\prod\db1\Log\db1-log-31102018.trn<br></p>
<h5 id="example-7">Example: 7</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Sql2017 -Database master -FilePath NUL
</code></pre>
<p>Performs a backup of master, but sends the output to the NUL device (ie; throws it away)<br></p>
<h5 id="example-8">Example: 8</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Sql2016 -Database stripetest -AzureBaseUrl https://az.blob.core.windows.net/sql,https://dbatools.blob.core.windows.net/sql
</code></pre>
<p>Performs a backup of the database stripetest, striping it across the 2 Azure blob containers at <a href="https://az.blob.core.windows.net/sql">https://az.blob.core.windows.net/sql</a> and <a href="https://dbatools.blob.core.windows.net/sql">https://dbatools.blob.core.windows.net/sql</a>, assuming that <br>
Shared Access Signature credentials for both containers exist on the source instance<br></p>
<h5 id="example-9">Example: 9</h5>
<pre><code>PS C:\> Backup-DbaDatabase -SqlInstance Sql2017 -Database master -EncryptionAlgorithm AES256 -EncryptionCertificate BackupCert
</code></pre>
<p>Backs up the master database using the BackupCert certificate and the AES256 algorithm.<br></p>
<h3 id="required-parameters">Required Parameters</h3>
<h5 id="sqlinstance">-SqlInstance</h5>
<p>The SQL Server instance hosting the databases to be backed up. <br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>True</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="inputobject">-InputObject</h5>
<p>Internal parameter <br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>True</td>
</tr>
<tr>
<td>Pipeline</td>
<td>true (ByValue)</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h3 id="optional-parameters">Optional Parameters</h3>
<h5 id="sqlcredential">-SqlCredential</h5>
<p>Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).<br />
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.<br />
For MFA support, please use Connect-DbaInstance.<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="database">-Database</h5>
<p>The database(s) to process. This list is auto-populated from the server. If unspecified, all databases will be processed.<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="excludedatabase">-ExcludeDatabase</h5>
<p>The database(s) to exclude. This list is auto-populated from the server.<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="path">-Path</h5>
<p>Path in which to place the backup files. If not specified, the backups will be placed in the default backup location for SqlInstance.<br />
If multiple paths are specified, the backups will be striped across these locations. This will overwrite the FileCount option.<br />
If the path does not exist, Sql Server will attempt to create it. Folders are created by the Sql Instance, and checks will be made for write permissions.<br />
File Names with be suffixed with x-of-y to enable identifying striped sets, where y is the number of files in the set and x ranges from 1 to y.<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td>BackupDirectory</td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="filepath">-FilePath</h5>
<p>The name of the file to backup to. This is only accepted for single database backups.<br />
If no name is specified then the backup files will be named DatabaseName_yyyyMMddHHmm (i.e. "Database1_201714022131") with the appropriate extension.<br />
If the same name is used repeatedly, SQL Server will add backups to the same file at an incrementing position.<br />
SQL Server needs permissions to write to the specified location. Path names are based on the SQL Server (C:\ is the C drive on the SQL Server, not the machine running the script).<br />
Passing in NUL as the FilePath will backup to the NUL: device<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td>BackupFileName</td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="incrementprefix">-IncrementPrefix</h5>
<p>If enabled, this will prefix backup files with an incrementing integer (ie; '1-', '2-'). Using this has been alleged to improved restore times on some Azure based SQL Database platforms<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td>False</td>
</tr>
</tbody>
</table>
<h5 id="replaceinname">-ReplaceInName</h5>
<p>If this switch is set, the following list of strings will be replaced in the FilePath and Path strings:<br />
instancename - will be replaced with the instance Name<br />
servername - will be replaced with the server name<br />
dbname - will be replaced with the database name<br />
timestamp - will be replaced with the timestamp (either the default, or the format provided)<br />
backuptype - will be replaced with Full, Log or Differential as appropriate<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td>False</td>
</tr>
</tbody>
</table>
<h5 id="noappenddbnameinpath">-NoAppendDbNameInPath</h5>
<p>A switch that will prevent to systematically appended dbname to the path when creating the backup file path<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td>False</td>
</tr>
</tbody>
</table>
<h5 id="copyonly">-CopyOnly</h5>
<p>If this switch is enabled, CopyOnly backups will be taken. By default function performs a normal backup, these backups interfere with the restore chain of the database. CopyOnly backups will not<br />
interfere with the restore chain of the database.<br />
For more details please refer to this MSDN article - <a href="https://msdn.microsoft.com/en-us/library/ms191495.aspx">https://msdn.microsoft.com/en-us/library/ms191495.aspx</a><br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td>False</td>
</tr>
</tbody>
</table>
<h5 id="type">-Type</h5>
<p>The type of SQL Server backup to perform. Accepted values are "Full", "Log", "Differential", "Diff", "Database"<br></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Alias</td>
<td></td>
</tr>
<tr>
<td>Required</td>
<td>False</td>
</tr>
<tr>
<td>Pipeline</td>
<td>false</td>
</tr>
<tr>
<td>Default Value</td>
<td>Database</td>
</tr>
<tr>
<td>Accepted Values</td>