dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Remove-DbaDatabase - no leftovers must stay behind

Open olegstrutinskii opened this issue 4 years ago • 3 comments

Summarize Functionality

Let Remove-DbaDatabase not just remove the database but and delete: files, backup, and restore history.

Is there a command that is similiar or close to what you are looking for?

No

Technical Details

Replicate option Remove behavior from context menu SSMS for a database.

  • [ ] Delete backup and restore history
  • [ ] Delete files from SQL Server disk
  • [:heavy_check_mark:] Drop all connections

olegstrutinskii avatar Dec 03 '21 14:12 olegstrutinskii

Hi @Zhunya - What left over files do you mean? I think all files are beeing deleted.

We could also remove the backup and restore history as SSMS suggests by default. That would be Remove-DbaDbBackupRestoreHistory -SqlInstance $db.Parent -Database $db.Name after a successful drop. Is that want you suggest? What name should the parameter get?

andreasjordan avatar Dec 20 '21 10:12 andreasjordan

Hi @andreasjordan After Remove-DbaDatabase finishes, it always leaves database files on the file system. Yeah, it will be nice to have backup/restore history deleted, parameter name may sound like RemoveBackupHistory

olegstrutinskii avatar Dec 22 '21 06:12 olegstrutinskii

Very strange, the files are deleted on my system. Can you run the command with verbose to see which of the different ways is used?

andreasjordan avatar Dec 22 '21 06:12 andreasjordan