I needed to setup a one-time backup for all databases on a SQL Server today, normally they are backed up with Veeam and I wanted to have native SQL backups.
I found that this query will built the backup commands for you.
DECLARE @path varchar(200)
SET @path =
‘D:backup’
SELECT
‘BACKUP DATABASE ‘+name+‘ TO DISK = ”’+@path+name+‘.bak” WITH INIT, STATS = 5;’
FROM
sys.databases
You can they copy the results of the query to a new query and start the backup of all your databses at once.