Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble

Search the Community

Showing results for tags 'automate sql backup'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Operating System Support
    • Windows Client OS Support
    • Windows Server Technologies
    • Mac, Linux, Chrome OS Support
  • Support and Discussion
    • Hardware Support and Discussion
    • Microsoft Application Support
    • General Software Support and Discussion
    • Internet, Networking and Security
    • Miscellaneous Support!
  • Essentials
    • Essential Guides
    • Essential Reviews
    • Essential Headlines
    • Essential Software
    • Essential Updates
  • Everything Else
    • The Game Zone
    • Programming, Debugging, Scripting...
    • Websites, Design and Code
    • Home Cinema, Television, Sky, Virgin Media, Freeview, Freesat
  • Windows Forum Chat
    • Windows Forum Related
    • Debates and Poll Station
    • Subscribers Lounge
    • The Lounge
    • NEW Members

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Skype


Website URL


Full Name


Location


Interests

Found 1 result

  1. How to Take backup of All of the Databases available on instance ? Sometimes Its required to take all of the Databases to be backed up periodically for more reliable backup process. If You require to get backup of any critical server's Database then You shouldn't do manually always, It will be better to automate the Process.SQL Query to take backup for All the Databases:- DECLARE @name VARCHAR(50) -- database name DECLARE @path VARCHAR(256) -- path for backup files DECLARE @fileName VARCHAR(256) -- filename for backup DECLARE @fileDate VARCHAR(20) -- used for file name-- specify database backup directorySET @path = 'D:\BKP\' -- specify filename formatSELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) DECLARE db_cursor CURSOR READ_ONLY FOR SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb') -- exclude these databasesOPEN db_cursor FETCH NEXT FROM db_cursor INTO @name WHILE @@FETCH_STATUS = 0 BEGIN SET @fileName = @path + @name + '_' + @fileDate + '.BAK' BACKUP DATABASE @name TO DISK = @fileName FETCH NEXT FROM db_cursor INTO @name END CLOSE db_cursor DEALLOCATE db_cursor copy the above query and save it with file name i.e- sqlbackupquery. The above query will give the Database backed up file (.bak) on the location You will set.You can run it over SQL server Management Studio (SSMS) or on sqlcmd.Query will give you the database backup in the described format below.DBName_YYYMMDD.BAKYou can run it from SQL CMD, with the required parameters. for Example see below.sqlcmd -S .\InstanceName -i C:\SQLBackup\SQLBackupQuery.sql (backup query file location and file name) If you require it to schedule the Process for backup of all SQL databases on the path where you want You can schedule it from Task Scheduler.To create a task go to Run (windows +R) - taskschd.msc and create a task. schedule it as per the requirement. Here define the action. Note- User should have the Admin right,Logon as batch Job Right. You also can automate on SQL Server Express from above query and Process.Enjoy, Now You will be able to take the databases backup in one go and schedule it as per your requirement for convenience and saving the time.Thanks,SanjeevPS- Please write to me or comment if you have any question/Feedback.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy