简体   繁体   English

移动数据库文件后,SQL Server到Azure的备份停止工作

[英]SQL Server backup to Azure stopped working after moving DB files

I have a database in SQL Server 2014 on premises. 我在内部的SQL Server 2014中有一个数据库。 For that database I have a backup to Azure storage configured using smart_admin.sp_set_db_backup procedure. 对于该数据库,我具有使用smart_admin.sp_set_db_backup过程配置的Azure存储的备份。

Recently I had to move the database files from one disk to another. 最近,我不得不将数据库文件从一个磁盘移动到另一个磁盘。 I detached database, moved files, reattached it. 我分离数据库,移动文件,然后重新连接它。

After that my backup stopped working. 之后,我的备份停止工作。 The function smart_admin.fn_backup_db_config shows that database backup record exists but database marked as is_dropped = 1 函数smart_admin.fn_backup_db_config显示存在数据库备份记录,但标记为is_dropped = 1数据库

Any attempt to enable or disable backup for this database fails with error: 尝试为此数据库启用或禁用备份失败,并显示以下错误:

SQL Server Managed Backup to Windows Azure cannot configure the database, 'DATABASE_NAME', because it either does not exist or is offline. 到Windows Azure的SQL Server托管备份无法配置数据库“ DATABASE_NAME”,因为它不存在或处于脱机状态。

Any way I can remove backup configuration information and create a new one? 有什么办法可以删除备份配置信息并创建一个新信息? One of the ideas I found is rename the database, but I cannot do that in production. 我发现的想法之一是重命名数据库,但是我不能在生产中这样做。

Vad's answer is close, but there can be more than one record in autoadmin_managed_databases for a given db_name . Vad的答案很接近,但是对于给定的db_nameautoadmin_managed_databases可以有多个记录。 You need to get the last record, which is the one with the max autoadmin_id . 您需要获取最后一条记录,该记录的最大值为autoadmin_id I picked the wrong one, and SQL Server repopulated the drop_date after I ran smart_admin.sp_set_db_backup or the 15 minute interval ran. 我选错了一个,在运行smart_admin.sp_set_db_backup或运行了15分钟的间隔后,SQL Server重新填充了drop_date

use msdb;
go

update [dbo].[autoadmin_managed_databases]
set drop_date = null
where [autoadmin_id]= (select max(autoadmin_id)
                       from [dbo].[autoadmin_managed_databases] 
                       where db_name = '<DROPPPED_DATABASE_NAME>')
go

Managed Backups - is_dropped flag set to Yes after detaching database and reattaching DB 托管备份-分离数据库并重新附加数据库后,is_dropped标志设置为Yes

Rename the database and set up managed backup again. 重命名数据库,然后再次设置托管备份。

Reference 参考

As I mentioned earlier I was not allowed to rename the database on the Production. 如前所述,我不允许在生产环境中重命名数据库。 So I found where it's marked as dropped and changed the value. 因此,我找到了标记为已删除的位置并更改了该值。 That helped. 有帮助。 Automated backups for the database started working again. 数据库的自动备份再次开始工作。 IMO what happened looks like a bug in SQL Server 2014. IMO发生的事情看起来像SQL Server 2014中的错误。

use msdb;
go

update [dbo].[autoadmin_managed_databases]
set drop_date = null
where [db_name] = '<DROPPED_DATABASE_NAME>'
go

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

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