S
Scott
Hello,
I have an interesting situation with my website and I'm not sure if it
would be better to ask here or a SQL forum. So I'll start here and see what
you all say.
In my asp.NET website I have two SQL express databases. One for logon
credentials and another for page content. I cannot backup the MDF files
because they are constantly in use. A while back I came accross the
following comand line that would do the backup:
-------------Command Line--------------------
c:\sqlcmd -S .\SQLExpress -i E:\ClientAccess\VP_v2.0\SQLBackup\Backup.sql -o
c:\sqlcmd -S .\SQLExpress -i
E:\ClientAccess\VP_v2.0\SQLBackup\Backup_Log.txt
------------------------------------------------
------------------Bckup.sql --------------------
USE [master]
GO
sp_attach_db "Database", "E:\ClientAccess\VP_v2.0\App_Data\Database.mdf"
GO
BACKUP DATABASE [Database] TO
DISK='E:\ClientAccess\VP_v2.0\SQLBackup\Database.bak' WITH FORMAT
GO
sp_detach_db [Database]
GO
sp_attach_db "ASPNETDB", "E:\ClientAccess\VP_v2.0\App_Data\ASPNETDB.MDF"
GO
BACKUP DATABASE [ASPNETDB] TO
DISK='E:\ClientAccess\VP_v2.0\SQLBackup\ASPNETDB.bak' WITH FORMAT
GO
sp_detach_db [ASPNETDB]
GO
--------------------------------------------------
This all works well and good but every so often the site stops working
because the file permissions on Database.mdf and ASPNETDB.MDF get changed to
something that doesn't allow the site to use the DB files and causes a
"Cannot open user default database. Login failed. Login failed for user 'NT
AUTHORITY\NETWORK SERVICE'." error when someone tries to log in. I have
enabled autiting on the directory these files are in and I think I've traced
it back to my backup script. Can anyone tell me if I'm doing something
wrong or perhaps offer a different solution? Maybe someone has seenthis
before and has fixed it.
-Scott
I have an interesting situation with my website and I'm not sure if it
would be better to ask here or a SQL forum. So I'll start here and see what
you all say.
In my asp.NET website I have two SQL express databases. One for logon
credentials and another for page content. I cannot backup the MDF files
because they are constantly in use. A while back I came accross the
following comand line that would do the backup:
-------------Command Line--------------------
c:\sqlcmd -S .\SQLExpress -i E:\ClientAccess\VP_v2.0\SQLBackup\Backup.sql -o
c:\sqlcmd -S .\SQLExpress -i
E:\ClientAccess\VP_v2.0\SQLBackup\Backup_Log.txt
------------------------------------------------
------------------Bckup.sql --------------------
USE [master]
GO
sp_attach_db "Database", "E:\ClientAccess\VP_v2.0\App_Data\Database.mdf"
GO
BACKUP DATABASE [Database] TO
DISK='E:\ClientAccess\VP_v2.0\SQLBackup\Database.bak' WITH FORMAT
GO
sp_detach_db [Database]
GO
sp_attach_db "ASPNETDB", "E:\ClientAccess\VP_v2.0\App_Data\ASPNETDB.MDF"
GO
BACKUP DATABASE [ASPNETDB] TO
DISK='E:\ClientAccess\VP_v2.0\SQLBackup\ASPNETDB.bak' WITH FORMAT
GO
sp_detach_db [ASPNETDB]
GO
--------------------------------------------------
This all works well and good but every so often the site stops working
because the file permissions on Database.mdf and ASPNETDB.MDF get changed to
something that doesn't allow the site to use the DB files and causes a
"Cannot open user default database. Login failed. Login failed for user 'NT
AUTHORITY\NETWORK SERVICE'." error when someone tries to log in. I have
enabled autiting on the directory these files are in and I think I've traced
it back to my backup script. Can anyone tell me if I'm doing something
wrong or perhaps offer a different solution? Maybe someone has seenthis
before and has fixed it.
-Scott