Skip to content

Move-DbaDbFile - when used with DeleteAfterMove and target drive does not have enough free space #9689

Open
@olegstrutinskii

Description

@olegstrutinskii

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

There is not enough space on the disk.
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
    + PSComputerName        : SRVSQLTST01

Cannot find path 'V:\MSSQL\DATA\db_binary_one.ndf' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (V:\MSSQL\DATA\db_binary_one.ndf:String) [Set-Acl], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetAclCommand
    + PSComputerName        : SRVSQLTST01 

Instance             : srvsqltst01
Database             : DB
LogicalName          : BinaryOne
Source               : D:\MSSQL\DATA\db_binary_one.ndf
Destination          : V:\MSSQL\DATA\db_binary_one.ndf
Result               : Success
DatabaseFileMetadata : Updated
SourceFileDeleted    : True

WARNING: [12:25:30][Edit-DatabaseState] Failed to set 'DB' to ONLINE
WARNING: [12:25:30][Move-DbaDbFile] Failed to set 'DB' to ONLINE! :
    Microsoft.Data.SqlClient.SqlException (0x80131904): Unable to open the physical file "V:\MSSQL\DATA\db_binary_one.ndf". Operating system error 2: "2(The system cannot find the file specified.)".

Could not restart database "DB". Reverting to the previous status.
ALTER DATABASE statement failed.
    at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
    at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteWithResults(String sqlCommand, Boolean retry)
Error Number:5120,State:6,Class:16.

Steps to Reproduce

Move-DbaDbFile -SqlInstance srvsqltst01 -Database DB -DeleteAfterMove -FileToMove $fileToMove

You have to move files bigger than you have free space on target drive.

Please confirm that you are running the most recent version of dbatools

1.1.142

Other details or mentions

Metadata for database for lost file was updated, so file points to new place.

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.19041.5848
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.5848
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2017 (RTM-CU31-GDR) (KB5046858) - 14.0.3485.1 (X64) Oct 17 2024 16:14:54 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.4780.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions