SQL Backup Scripts

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.

Advertisements
This entry was posted in Backups, SQL and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s