Page History
Options for Backup
OptionsPolicy
To backup policies create usage with minimal required options use the following options:
command:
SQLsafeCmd Create-Policy Backup <policy_name> -IncludeInstance <name> -IncludeDatabases <db_name> [<db_name> ...] [options] [-BackupType <type> [backup options] [-BackupType <type> [backup options] ...]]
-BackupType <type>
Specifies backup type for policy.
<type> - Full, Differential, Diff, Log
Option can be used one or more times. Optional.
Note: the default type is "Full" with default settings.Option | Description |
---|---|
-ActionType <action> | Specifies the policy action. <action> - SqlAgent, SqlSafeBackupAgent, MonitorOnly. Note: the default is the SqlAgent action. |
-RestrictRun [on|off] | [on|off] - Enable/Disable the policy. |
-Description <description> | <description> - specifies the policy description. |
- InstanceNameIncludeInstance <instance_name> | <instance_name> - specifies the source instance name to include in policy. Option can be used one or more times. There must be NO OPTIONS between -IncludeInstance and -IncludeDatabases options. Note: this parameter is Note: it is required. |
- DatabaseNameIncludeDatabases <db_name> [<db_name> ...] | <db_name> - specifies the database to restore[<db_name> ...] - one or more names of database(s) to include in policy. Special keywords: {All}, {AllSystem}, {AllUser}. Note: it is required for each -IncludeInstance option. |
- Server <serverExclude <db_name> [<db_name> ...] | <db_name> [<db<server_name> - specifies the source server. Note: it is optional. |
-RetryWrites <interval> <retry_time> <total_time> | On a network file error, retry every <interval> seconds for up to <retry_time> seconds. Total retry time allowed is <total_time> minutes. |
-SourceBackupPolicy <policy_name|GUID> | <policy_name|GUID> - specifies the backup policy for source database. |
-BackupEncryptionPassword <pwd> | <pwd> - specifies the password for encrypted source backup file. |
...] - one or more names of database(s) to not backup. |
Email Options
You can set email notifications for backup policy operations by using the following options:
Options | Description |
---|---|
| <email> - specifies where to send the notification. <on_event> - specifies the event on which to send the notification. Valid events are: OnError, OnSkip, OnCancel, OnWarning, OnSuccess. The default is no event. <frequency> - specifies the notification frequency. Valid values: Once, Always, Never. The default is never. |
Backup Options
To backup policies use the following option:
Option | Description |
---|---|
-BackupType <type> | Specifies backup type for policy. <type> - {Full, Differential, Diff, Log}. Option can be used one or more times. Note: the default type is "Full" with default settings. This parameter is optional. |
Available Options
There are available options for -BackupType option:
Option | Description |
---|---|
-CompressionLevel <level> | The compression level used for the backup. <level> - {ispeed, isize, 0, 1, 2, 3, 4}. Note: if the compression level is not specified, ispeed is the default. |
-EncryptionType <type> | The type of encryption used to encrypt the backup. <type> - {AES128, AES256}. |
-BackupEncryptionPassword <pwd> | <pwd> - specifies the password for encrypted backup file. |
-Verify <yes|no> | Verifies the backup set after backup is complete. |
-IncludeLogins <yes|no> | For backup, includes the database logins in the backup file. For restore, creates the logins from the backup file on the destination server. Note: this parameter is optional. |
-GenerateMap <yes|no> | Generates maps. Note: for InstantRestore and SQL virtual database. |
-Threads <number> | <number> - specifies the number of threads that should be used to distribute the backup process across multiple processors. |
-Checksum <yes|no> | Instructs SQL Server to generate backup checksums during a backup, or verify backup checksums during a verify or restore. Note: for SQL 2005 and later only. This parameter |
Account Options
The following account options help you perform restore policy operations:
Options | Description |
---|---|
-UseAgentAccount <yes|no> | Specifies the Agent account for accessing to files. Note: it is optional. By default, the policy uses Agent account. |
-WindowsUsername <domain\user> | <domain\user> - specifies the user name, used when writing/reading to files during restore. |
-WindowsPassword <pwd> | <pwd> - specifies the password. |
Target Options
The following target options help you perform restore policy operations:
Options | Description |
---|---|
-TargetInstance <instance_name> | <instance_name> - specifies the target instance. Note: it is required. |
-TargetDatabase <db_name> | <db_name> - specifies the new database. Note: it is required. |
-TargetServer <server_name> | <server_name> - specifies the target server. Note: it is optional. |
-LogLocation <path> | <path> - specifies where to store the database log files. Note: the default value is the current target database log files location. |
-DataLocation <path> | <path> - specifies where to store database data files. Note: the default value is the current target database data files location. |
-RecoveryMode <mode> | Specifies the database state after restore action. <mode> NoRecovery, Standby, Recovery. |
-DisconnectUsers <yes|no> | Disconnects all users from the target database before the restore operation begins. Note: it is optional. |
-ContinueAfterError <yes|no> | Instructs SQL Server to continue the operation despite encountering errors such as invalid checksums. Note: for SQL 2005 and later only. This parameter it is optional. |
-CopyOnly <yes|no> | Specifies that the backup does not affect the normal sequence of backups. Note: for For SQL 2005 and later only. This parameter is optional. |
-IncludeLogins ReadWriteFileGroups <yes|no> | For Instructs SQL Server to perform a partial backup, includes the database logins in the backup file. For restore, creates the logins from the backup file on the destination server. Note: it is optional. |
-KeepReplication <yes|no> | Preserves replication settings when restoring a published database to a server other than that on which it was created. Note: it is optional. |
which includes the primary filegroup and any read-write secondary filegroups. Note: for SQL 2005 and later only. This parameter is optional. | |
-TruncateTransactionLog <yes|no> | Removes inactive entries for transaction log in "Log" backup option. Optional. Note: by default, this option is enabled. |
-Location <type> | Specifies backup storage type. <type> - {Single File, TSM, Striped Files, Data Domain, S3 Cloud}. Note: The default value is "Single File". This parameter is optional. |
-Overwrite <yes|no> | Overwrites existing archive if one exists. Note: The default value is "no". This parameter is optional. |
-RetryWrites <interval> <retry_time> <total_time> | On a network file error, retry every <interval> seconds for up to <retry_time> seconds. Total retry time allowed is <total_time> minutes. |
-FailOnMirrorError <yes|no> | To abort backup if a mirror location reports a failure. Note: by default, this option is disabled. This parameter is optional. |
-MirrorFile <filename> | Specifies additional backup archive files to be used for mirroring backups. <filename> - specifies the backup archive files. Note: use once for each additional mirror. Up to two mirrors may be specified. |
-DeleteMirror <n><time_period> | After a backup successfully completes, delete mirrors that are older than the specified amount of time. <n> - amount of time. <time_period> - {minutes, hours, days, weeks, months}. There must be NO SPACE between <n> and <time_period>. E.g., -deletemirror 2hours. Note: if you use the space between <n> and <time_period>, the mirror filename will be automatically generated with the following pattern: <instancename>_<databasename>_<backuptype>_<timestamp>.safe where the <timestamp> is in UTC time and in the form of YYYYMMDDHHMM. |
-BackupFile <filename> | Specifies additional backup archive files to be used for striping backups. <filename> - specifies the backup archive files. Note: use once for each additional stripe. |
-Delete <n><time_period> | After a backup successfully completes, delete archives that are older than the specified amount of time. <n> - amount of time. <time_period> - {minutes, hours, days, weeks, months}. There must be NO SPACE between <n> and <time_period>. E.g., -delete 2hours. Note: if you use the space between <n> and <time_period>, the backup archive filename will be automatically generated with the following pattern: <instancename>_<databasename>_<backuptype>_ <timestamp>.safe where the <timestamp> is in UTC time and in the form of YYYYMMDDHHMM. |
-UseAgentAccount <yes|no> | Specifies Agent account for accesing to files. Note: by default, the policy uses Agent account. This parameter is optional. |
-WindowsUsername <domain\user> | <domain\user> - specifies user name, used when writing to remote files during backup. |
-WindowsPassword <pwd> | <pwd> - specifies password. |
-BucketName <bucket_name> | <bucket_name> - specifies the cloud bucket name. |
-SecretKey <key> | <key> - specifies the cloud secret name. |
-AccessKey <key> | <key> - specifies the cloud access key. |
-FileSize <file_size> | <file_size> - specifies the cloud file size. |
-Region <region> | <region> - specifies the cloud region. |
Schedule Options
You can schedule a restore backup policy by using the following options:
Options | Description |
---|---|
-Schedule <occurs_type> | Specifies the schedule type (occurs type). <occurs_type> - OnDemand, Daily, Weekly, Monthly. |
-Every <n> | <n> - specifies Specifies how often the policy runs. It depends on the schedule type. For Daily: every <n> day(s). For Weekly: every <n> week(s). For Monthly: every <n> month(s). Note: the default value is "1". |
-Day <day> | <day> - specifies a day of the week or a day of a month. Note: it is valid only with Weekly, Monthly schedule types. Valid values for Weekly: MON - SUN and * (every day). SUN is default. Valid values for Monthly: MON - SUN, Weekday, WeekendDay, Day or number 1 - 31. Is required when -MonthDay option is used. |
-MonthDay <month_day> | Specifies how often the policy runs. <month_day> - FIRST, SECOND, THIRD, FOURTH, LAST use with -Day option. LASTDAY - the policy runs on the last day of the month. |
-StartTime <time> | <time> - specifies the time of day that the policy runs. Note: it is required with a "once" frequency. The default value is the current local time when policy creates. |
-EndTime <time> | <time> - specifies the time of day that the policy ends. Note: it is is not valid in a "once" frequency. The default value is the "23:59:59". |
-Frequency <n><time_period> | Specifies daily frequency (how often the policy runs within a day). <n> - amount of time. <time_period> - {hour, minute}. E.g., -Frequency 2hours. Special keyword: Once. E.g., -Frequency Once. |
-StartDate <date> | <date> - specifies the date that the policy starts. Note: it is optional.The the default value is the current date. It is optional. |
-EndDate <date> | <date> - specifies the last date that the policy is scheduled to run. Note: it is optional.By by default, the schedules have no ending date. It is optional. |
Note: you can optionally specify restore backup job occur schedule.
Email Options
You can set email notifications for restore policy operations by using the following options:
<email> - specifies where to send notification.
<on_event> - specifies the event on which send notification.
Valid events are: OnError, OnSkip, OnCancel, OnWarning, OnSuccess.
The default is no event.
<frequency> - specifies the notification frequency.
Valid values: Once, Always, Never.
The default is never.
For detailed descriptions and available options, see the CLI Help (SQLsafecmd help create-policy
).