DBATools

If you need to restore multiple MS SQL DB’s from BAK files, this Community driven Powershell module does the trick (among a whole lot more..)

install in powershell 7.0 with

install-module dbatools

Get help by issuing

get-help *Restore*

and details

get-help Restore-DbaDatabase

Restore your files in specific folder with

restore-dbadatabase -sqlinstance servername -path c:\temp\backup -withreplace

Backup multiple databases

$server = 'servername'
$dblist = 'dbname01','dbname02','dbname03' 
$path = '\\fileshare\Backups\'
 
Backup-DbaDatabase -SqlInstance $server -Database $dblist -Path $path -Type Full -CopyOnly

Backup all databases

$server = 'servername' 
$path = '\\fileshare\Backups\' 
 
Backup-DbaDatabase -SqlInstance $server -Path $path -Type Full -CopyOnly

Also after a SQL DB restore it is necessary to re-map SQL user logins.
Windows logins SID is not affected, but a restored SID is not the same as the old. So a T-SQL script like this will resolve nicely

USE DBname
ALTER USER [DBuser] WITH LOGIN = [Dbuser]
GO

More articles