Invoke-BackupRestoreSQLDB
SYNOPSIS
Perform a backup and restore of a SQL Server database.
SYNTAX
DESCRIPTION
This function performs the following operations: - Backs up the source database on the source server to a shared location. - Lists the security settings of the target database. - Restores the target database using the backup file, overwriting it if necessary. - Reapplies the security settings to the restored database. - Cleans up the backup file after the operation.
EXAMPLES
EXAMPLE 1
Backs up "TestDB" from "SQLSource" and restores it as "TestDB_Copy" on "SQLDestination".
EXAMPLE 2
Backs up "ProdDB" from "SQLSource" and restores it as "ProdDB_Copy" on "SQLDestination", reapplying security settings.
PARAMETERS
-source
The name of the source database and SQL Server in the format: `%databasename% - %databaseserver%`.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-target
The name of the target database and SQL Server in the format: `%databasename% - %databaseserver%`.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.