Last active
July 12, 2019 06:42
-
-
Save isummation/2aa74e0ee0e4ab195c4804bbae9e127a to your computer and use it in GitHub Desktop.
Create script to take backup for all database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'BACKUP DATABASE [' + name + '] TO DISK = ''C:\sqlbackup\' + name + '.bak''' | |
FROM sys.databases ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'RESTORE DATABASE [' + name + '] FROM DISK = ''/var/opt/mssql/data/' + name + '.bak'' WITH MOVE ''' + name + ''' to ''/var/opt/mssql/data/' + name + '.mdf'', MOVE ''' + name + '_log'' to ''/var/opt/mssql/data/' + name + '.ldf''' | |
FROM sys.databases ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment