简体   繁体   English

在Linux VM上托管的SQL Server上还原备份

[英]Restoring backup on sql server hosted on linux VM

I am trying to restore a database backup on SQL server hosted on linux VM. 我正在尝试在Linux VM上托管的SQL Server上还原数据库备份。 Backup files are placed on a windows file system network path. 备份文件放置在Windows文件系统网络路径上。 I mounted that path in linux /home/user/WinMap/ 我在Linux / home / user / WinMap /中安装了该路径

Now when I am trying to restore database backup using restore screen, I see the path like 现在,当我尝试使用还原屏幕还原数据库备份时,我会看到类似

C:\\var\\opt\\mssql\\data C:\\ var \\ opt \\ mssql \\ data

. I can no where see my mounted path that is 我在哪里看不到我的挂载路径

/home/user/WinMap/ / home /用户/ WinMap /

so that I can restore my backups. 这样我就可以还原备份了。

Any idea how can I handle linux file system in SQL server would be highly appreciated. 我将如何在SQL Server中处理Linux文件系统的任何想法将不胜感激。

TIA TIA

Not using SSMS.. and using references from here: Restore a SQL Server database from Windows to Linux 不使用SSMS ..并从此处使用引用: 将SQL Server数据库从Windows还原到Linux

Next step,once you placed backup file in linux is to move the backup file to /var/opt/mssql 下一步,一旦您将备份文件放置在Linux中,就是将备份文件移至/var/opt/mssql

This can be done using 这可以使用

Move the backup file At this point, the backup file is on your Linux server. 移动备份文件此时,备份文件位于Linux服务器上。 Before restoring the database to SQL Server, you must place the backup in a subdirectory of /var/opt/mssql. 将数据库还原到SQL Server之前,必须将备份放置在/ var / opt / mssql的子目录中。

Open a Terminal on the target Linux machine that contains the backup. 在包含备份的目标Linux计算机上打开一个终端。

Enter super user mode. 进入超级用户模式。

sudo su 苏多苏

Create a new backup directory. 创建一个新的备份目录。 The -p parameter does nothing if the directory already exists. 如果目录已经存在,则-p参数不执行任何操作。

mkdir -p /var/opt/mssql/backup  

Move the backup file to that directory. 将备份文件移到该目录。 In the following example, the backup file resides in the home directory of user1. 在以下示例中,备份文件位于user1的主目录中。 Change the command to match the location of AdventureWorks2014.bak on your machine. 更改命令以匹配AdventureWorks2014.bak在计算机上的位置。

mv /home/user1/AdventureWorks2014.bak /var/opt/mssql/backup/

Exit super user mode. 退出超级用户模式。

exit

Now to restore ,you have to use SQLCMD.. 现在要还原,您必须使用SQLCMD。

In the same terminal, launch sqlcmd. 在同一终端中,启动sqlcmd。 The following example connects to the local SQL Server instance with the SA user. 下面的示例使用SA用户连接到本地SQL Server实例。 Enter the password when prompted or specify the password with the -P parameter. 出现提示时输入密码,或使用-P参数指定密码。

sqlcmd -S localhost -U SA  

After connecting, enter the following RESTORE DATABSE command, pressing ENTER after each line. 连接后,输入以下RESTORE DATABSE命令,每行之后按ENTER。 The example below restores the AdventureWorks2014.bak file from the /var/opt/mssql/backup directory . 下面的示例从/var/opt/mssql/backup directory还原AdventureWorks2014.bak文件。

RESTORE DATABASE AdventureWorks
FROM DISK = '/var/opt/mssql/backup/AdventureWorks2014.bak'
WITH MOVE 'AdventureWorks2014_Data' TO '/var/opt/mssql/data/AdventureWorks2014_Data.mdf',
MOVE 'AdventureWorks2014_Log' TO '/var/opt/mssql/data/AdventureWorks2014_Log.ldf'
GO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM