Description
This article explains how to use ApexSQL Backup command line interface (CLI) and create output files.
To start the ApexSQL applications GUI via the command line interface enter the product name. For example apexsqlbackup.exe
The CLI must be started using apexsqlbackup.com
Format of switches
The following ApexSQL Backup switches are available:
Command:
/c:arg [ /cmd ]: Command: [Backup | Restore | LogShipping | Policy | Print]
Server options:
/s:arg [ /server ]: SQL Server instance name ((local) if omitted)
/dbs:arg [ /databases ]: Database name
Backup options:
/bt:arg [ /backuptype ]: Backup type: [Full | Differential | Transaction Log]
/bsn:arg [ /name ]: Backupset name (if omitted default destination is used)
/des:arg [ /description ]: Backupset description
/l:arg [ /destinations ]: Backup destination
/m:arg [ /mirror ]: Backup mirror (if omitted mirror is not executed)
/com:arg [ /compression ]: Native compression type Default (if omitted): [Default | Enabled | Disabled]
/ui [ /useinit ]: Initialize media (suppressed by default)
/uf [ /useformat ]: Format media (suppressed by default)
/co [ /copyonly ]: Copy only (suppressed by default)
/rbsd:arg [ /retainbackupsetdays ]: Retain backup sets
/nbs [ /donotcheckbackupset ]: Do not check backup set
/vb [ /verifybackup ]: Verify backup when finished
/pc [ /performchecksum ]: Perform checksum before writing to media
/coe [ /continueonerror ]: Continue on error
/encalg:arg [ /encryptionalghoritm ]: Encryption algorithm: [AES 128 | AES 192 | AES 256 | Triple DES]
/enctyp:arg [ /encryptiontype ]: Encryption type: [Server certificate | Asymmetric key]
/encn:arg [ /encryptionname ]: Encryptor name
/fg:arg [ /filegroups ]: Database filegroups
Backup to Azure options:
/cr:arg [ /credential ]: Credential for connecting to Azure
/url:arg [ /URL ]: Backup destination
Restore options:
/kconn [ /killconn ]: Kill all existing connections
/ow [ /overwrite ]: Overwrite existing database
/sbf:arg [ /specificbackupfiles ]: Specific backup files
/rt:arg [ /restoretype ]: Restore type [LatestFull (Last full backup) | latestfulldiff (Last full and differential backups) | latestfulldifftlog (Last full, differential and transaction log backups)]
/uddf [ /usedefaultdatafolder ]: Use default data folders
/dff:arg [ /datafilesfolder ]: Data files folder
/lff:arg [ /logfilesfolder ]: Log files folder
/fs:arg [ /folderscan ]: Folder scan (Path Filename-pattern subfolders true/false) i.e. C:\Temp Filename_Pattern true
Log shipping options:
/tls:arg [ /tlogsource ]: Log shipping source format: server_name database_name local_folder network_folder backup_name backup_description backup_filename
backup_name (if omitted default value "%Database% - %BackupType% backup" is used)
backup_description (if omitted default value "%BackupType% backup of %Database% on %Date% %Time24h%" is used)
backup_filename (if omitted default value "%Database%_%BackupType%_%Date%_%Time24h%.bak" is used)
/tld:arg [ /tlogdests ]: Log shipping destination format: server_name database_name recovery_model local_folder data_folders
/ides [ /initdest ]: Initialize destinations with full backup (True | False) (enabled if omitted)
Scheduler options:
/sch:arg [ /scheduler ]: Scheduled job (Frequency (Once | Daily | Weekly | Monthly) dd: (day) mm: (month) yyyy: (year) hh: (hour) mm: (minute) ss: (second)) (optional wb: (weekday), on: (on specific day), first: (first specific day in a month) shh: smm: sss: (starting hour, minute, second) ehh: emm: ess: (ending hour, minute, second))
i.e. /scheduler: weekly every:1 wd:monday,tuesday every hh:8 mm:22 shh:5 smm:20 sss:54 ehh:8 emm:8 ess:10
i.e. /scheduler: monthly every:2 on:first,Monday,Wednesday every hh:8 mm:22 shh:5 smm:20 sss:54 ehh:8 emm:8 ess:10
/bsch:arg [ /backupscheduler ]: Log shipping backup scheduled job
/rsch:arg [ /restorescheduler ]: Log shipping restore scheduled job
Deploy policy options:
/pn:arg [ /policyname ]: Deploy backup policy
/pe:arg [ /policyencryptor ]: Deployer policy encryptor (per SQL server instance)
/ps:arg [ /policysource ]: Deploy policy to multiple databases (per SQL server instance)
Notification options (alerting):
/notify:arg [ /notifyevents ]: Notification options: events [failed|success] and email addresses
i.e. /notify: events:failure,success emails:email1@domain1.com,email2@domain2.com
Print options:
/fi:arg [ /filter ]: Filter options: [numeletoprint | lastndays], where numeletoprint = last number of elements to print, lastndays = last N days
Additional options:
/? [ /help ]: Shows CLI help
/af:arg [ /argfile ]: An XML file with options
/cw:arg [ /console_width ]: Specifies the width of console output
/f [ /force ]: Overrides existing file of same name
/out:arg [ /out_to ]: Redirects console output to specified file
/t [ /test ]: Outputs parsed command line switches without taking any actions
/v [ /verbose ]: Prints messages that are suppressed by default
/slt [ /silent ]: Disables all output to console
Special keys
To abort program execution, use Ctrl+C or Ctrl+Break
The following CLI example creates a backup of DEMO01 database
apexsqlbackup.com /s: ZWERKA\SQL2014 /dbs: DEMO01 /c:Backup /bt:Full /com:Default /vb /pc /coe /scheduler: weekly every:1 wd:monday,tuesday every hh:8 mm:22 shh:00 smm:20 sss:30 ehh:8 emm:8 ess:45
The following CLI example creates a differential backup of DEMO02 database
apexsqlbackup.com /s: ZWERKA\SQL2014 /dbs: DEMO02 /c:Backup /bt:Differential /bsn:"%DATABASE% - %BACKUPTYPE%" /des: %DATABASE%%TIME12H% /encalg:AES256 /enctyp:Server /scheduler: monthly every:2 on:first,Monday,Wednesday every hh:4 mm:30 shh:5 smm:20 sss:54 ehh:22 emm:45 /notify:events:failure emails:email1@domain1.com
The following CLI example perform a restore of DEMO03 database
apexsqlbackup.com /s: ZWERKA\SQL2014 /dbs: DEMO01 /c:Restore /ow /kconn /sbf: C:\Temp\DEMO03-January.bak /rt:LatestFull /uddf /v
The following CLI example perform a log shipping of DEMO04 database to DEMO05 database
apexsqlbackup.com /c:LogShipping /tls:server:ZWERKA\SQL2014 database:DEMO4 local:C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\Backup netlocation:C:\Temp /tld:server:ZWERKA\SQL2012 /database:DEMO5 recovery:Read-only folder:D:\Temp disconn:True /backupscheduler: once dd:05 mm:08 yyyy:2015 hh:05 mm:00 ss:00 /restorescheduler: once dd:05 mm:08 yyyy:2015 hh:05 mm:30 ss:00
The following CLI example creates a backup of DEMO01 database on Azure server with credential backupToAzure
apexsqlbackup.com /s: ZWERKA\SQL2014 /dbs: DEMO01 /cr: BackupAzure /url: https:\\zwerkabackup.blob.core.windows.net\backups /cr: backupToAzure /scheduler: weekly every:1 wd:monday,tuesday every hh:8 mm:22 shh:00 smm:20 sss:30 ehh:8 emm:8 ess:45
© ALL RIGHTS RESERVED. 使用条款 隐私 Cookie Preference Center