在Linux中安装了mssql的数据库并存了一些数据,使用sqlcmd备份的时候
backup database xxxx TO DISK='/root/xxx/db.bak'
发现总是报错没有权限,
如
Msg 3201, Level 16, State 1, Server test-srv, Line 7
Cannot open backup device '/root/xxxx/db_20210304.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Server test-srv, Line 7
BACKUP DATABASE is terminating abnormally.
可是我已经是root用户了,怎么会还报告没有权限了,后来想起来也许在sqlcmd中的执行用户并非root,查了下passwd文件,果然有一个mssql的用户,它的home目录是/var/opt/mssql,尝试修改备份命令
backup database xxxx TO DISK='/var/opt/mssql/db.bak'
成功
Processed 480 pages for database 'xxxx', file 'xxxx' on file 1.
Processed 2 pages for database 'xxxx', file 'xxxx' on file 1.
BACKUP DATABASE successfully processed 482 pages in 0.110 seconds (34.197 MB/sec).