Link Search Menu Expand Document

SqlBak-CLI documentation

target section

In the target section in the restore job settings file, the data for a database connection is specified.

{
	"type": "mssql",
	...
}

The fields that should be filled in, in the target section, depend on the type of database to which the connection should be set. The type is specified in the type field. Currently, only Microsoft SQL Server can be specified as a data sink.

type

The type of object to which a restore should be made.

VALUES:

New DBMS types will be added in the future.

close_connections

This parameter is for closing existing connections to the database before restore. Defaults to true.

restore_items

List of database names whose backups need to be found in the repository and restored.

"databases": [
{
	"source_name": <string>,
	"target_name": <string>
},
...
...
]

source_name

The name of the source object (database) that is stored in the storage.

target_name

A new name for a restored object (database). If the object already exists, it will be overwritten.

File Overrides for SQL Server

For SQL Server, the paths for the database files can be overridden. The new paths for the database files are specified in the files field. This is useful if you want to restore a database under a different name on the same server as the original database. It will not be possible to restore a backup without specifying new paths to the database files, since the paths to the database files are recorded in the backup and are already used for the original database.

"files": [
	{
		"logical_name": <string>,
		"physical_name": <string>
	}
		

Examples

Settings for a local SQL Server connection to backup two databases: DataOne and MediaOne:

...

"target": {
	"type": "mssql",
	"data_source": ".",
	"is_integrated_security": false,
	"trust_server_certificate" : true,
	"user_name": "sa",
	"user_password": "secret-password",
	"databases": [
		{
		   "source_name": "wordpress",
		   "target_name": "wordpress"
		},
		{
		   "source_name": "logs",
		   "target_name": "logs"
		},
		{
		   "source_name": "market",
		   "target_name": "market"
		}
	]
}

...

Database restore under a different name with new paths for data files:

...

"target": {
	"type": "mssql",
	"source_id": "MSSQL",
	"data_source": ".",
	"trust_server_certificate": true,
	"is_integrated_security": true,
	"user_name": "sql-user-name",
	"user_password": "sql-user-password",
	"databases": [
	{
		"source_name": "DataOne",
		"target_name": "DataOne-R1",
		"files": [
			{
				"logical_name": "DataOne",
				"physical_name": "%app_mssql_data_directory%\\DataOne-R1.mdf"
			},
			{
				"logical_name": "DataOne_log",
				"physical_name": "%app_mssql_log_directory%\\DataOne-R1.ldf"
			}
		]
	  },
	  {
		"source_name": "MediaOne",
		"target_name": "MediaOne"
	  }
	],
	"close_connections": true
}
...

More examples in the Samples section.