Dewiced
asked on
SQL database backup script
Greetings,
I'm trying to backup databases from remote SQL server to specific location trough powershell and set it as automated task. I have sysadmin on SQL server and full access to folder where i want to put backups. I'm not familiar with scripting so any help would be welcome. Until now i searched couple of sites but all the examples were only focused on local database. So all i need is that i run script from server X which will backup all databases from server A to shared folder on server B using powershell.
Any help would be appreciated.
Thanks in advance
I'm trying to backup databases from remote SQL server to specific location trough powershell and set it as automated task. I have sysadmin on SQL server and full access to folder where i want to put backups. I'm not familiar with scripting so any help would be welcome. Until now i searched couple of sites but all the examples were only focused on local database. So all i need is that i run script from server X which will backup all databases from server A to shared folder on server B using powershell.
Any help would be appreciated.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you.
You both were very helpfull and i managed to fix the whole thing by following the instructions from Daniel.
Thanks again.
You both were very helpfull and i managed to fix the whole thing by following the instructions from Daniel.
Thanks again.
To do a SQL Server backup in SQL Server, you will need to use the SMO SqlBackup method. In SQL Server 2008, you will need to load Microsoft.SqlServer.SmoExt
Cannot find type [Microsoft.SqlServer.Manag
Other assemblies you may want to load are:
?123456 [System.Reflection.Assembl
Also another point to note is the types of backup you can do. BackupActionType specifies the type of backup. Valid values for this option are Database, Files, Log
Here’s the script. This script is for one specific database. If you want to use this for several database, you will just need to use this code inside a loop.
Better yet, put this in a function, and call this in a loop. I will try to do that sometime soon.
?1234567891011121314151617