Assuming you've the right permissions, try:
SqlCmd -E -S Server_Name –Q "BACKUP DATABASE [Name_of_Database] TO DISK=’X:PathToBackupLocation[Name_of_Database].bak'"
Note: Instead of -E
, you can use -U
and -P
to specify user credentials.
Then to restore, use the following syntax:
SqlCmd -E -S Server_Name –Q "RESTORE DATABASE [Name_of_Database] FROM DISK=’X:PathToBackupFile[File_Name].bak'"
Source: Backup and Restore Your SQL Server Database from the Command Line.
To export specific data, see: How to export data as CSV format from SQL Server using sqlcmd?