I try to backup database using code below :
backup database RestaurantManagement to disk = 'd:\'
sqlserver always show the message below :
Msg 3201, Level 16, State 1, Line 3
Cannot open backup device 'd:\'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 3
BACKUP DATABASE is terminating abnormally.
How can i code it ? help...
You need to provide the backup file name, like this:
backup database RestaurantManagement to disk = 'd:\backups\RestaurantManagement.bak'
Are you a member of the appropriate sql role? Does the account which Sql Server is running under have permissions to the path? Are you sure the media is available on the server? What I mean is, you may have a d: on your machine, but the paths you give are for the remote server.
The error you're getting indicates there's no d: drive, or no folder named backups.
I would double check all those things.
Related
We have a custom backup solution utilizing the ibx controls in Delphi to perform nightly automatic backups. As part of our current validation for a successful backup, we read the output logs generated by the backup looking for the "closing file, committing and finishing" verbiage that's last in the log file. Additionally we perform a full restore to a separate area to ensure the ibk file is valid. That's turning out to be problematic in terms of available drive space so looking for other ideas to make sure the backup is successful.
How else might we ensure that our ibk file is valid?
Jeff,
Not sure what your database size or backup file size is, and if they are too big for the remaining disk space. Can you share the database and backup size details?
Older InterBase (2017 and earlier) had a way for the command line tool, gbak, to pipe the output from the backup to another gbak process restoring from the backup. This would allow you to save the disk space on the backup file. But, since you are using the IBX backup/restore service, this is not possible. Also, InterBase 2020 has a different backup format which requires random (not sequential) write access to the backup file, thereby not allowing any pipe output even via the 'gbak' command line tool.
Here are a couple of ways to "reduce" the disk storage requirements that may work for you.
** Backup file **
You can have the InterBase backup service (from your application) store the target backup file in an external storage medium (HDD, USB stick etc., or a SAN disk/network file share). The backup/restore service can read/write backup file(s) from network shares/external medium.
** Restored database **
When restoring the database you can use the service parameter option UseAllSpace (http://docwiki.embarcadero.com/Libraries/Sydney/en/IBX.IBServices.TRestoreOptions), equivalent to gbak option "-use_all_space". This will save you about 20% space on restored data pages.
Turn off index creation, thereby reducing page consumption (possibly quite a bit depending on your index definitions). But, you will lose index validation because of this. "DeactivateIndexes" option (gbak option "-inactive") in the same page above.
Restore the database to a remote InterBase server with its own storage medium, or, to an attached USB stick or SAN disk. Since you are using the restored database only for validating the backup file, you can have this restored database on a slower I/O medium or a slower server over the network.
I have noticed a failure of a differential backup in our maintenance plan. It appears to be the result of an attempted enterprise vault copy but cannot confirm this at the present time. The previous full backup was done at 5:00pm and the failure occurred at 11:30pm.
enter image description here
The log file is here:
Microsoft(R) Server Maintenance Utility (Unicode) Version 10.50.6220
Report was generated on "server_name".
Maintenance Plan: db_name backup Differential
Duration: 00:00:00
Status: Warning: One or more tasks failed.
Details:
Back Up Database Task (server_name)
Backup Database on Local server connection
Databases: DB_NAME
Type: Differential
Append existing
Task start: 2017-07-12T23:30:01.
Task end: 2017-07-12T23:30:02.
Failed:(-1073548784) Executing the query "BACKUP DATABASE [DB_NAME] TO DISK = N'C:..." failed with the following error: "Cannot perform a differential backup for database "DB_NAME", because a current database backup does not exist. Perform a full database backup by reissuing BACKUP DATABASE, omitting the WITH DIFFERENTIAL option.
BACKUP DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Command:EXECUTE master.dbo.xp_create_subdir N''C:\Full Backups\Differentials\DB_NAME''
GO
BACKUP DATABASE [DB_NAME] TO DISK = N''C:\Full Backups\Differentials\DB_NAME\DB_NAME_backup_2017_07_12_233001_9226889.bak'' WITH DIFFERENTIAL , NOFORMAT, NOINIT, NAME = N''DB_NAME_backup_2017_07_12_233001_9070642'', SKIP, REWIND, NOUNLOAD, COMPRESSION, STATS = 10
GO
declare #backupSetId as int
select #backupSetId = position from msdb..backupset where database_name=N''DB_NAME'' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N''DB_NAME'' )
if #backupSetId is null begin raiserror(N''Verify failed. Backup information for database ''''DB_NAME'''' not found.'', 16, 1) end
RESTORE VERIFYONLY FROM DISK = N''C:\Full Backups\Differentials\DB_NAME\DB_NAME_backup_2017_07_12_233001_9226889.bak'' WITH FILE = #backupSetId, NOUNLOAD, NOREWIND
GO
Problem is that I can't seem to find this new full backup that has been created that the differential backup from 12:30am have as their base? Is there a way to find what base file a differential points to?
One way is to automate this job through PowerShell scripts (easily available on various forums), where you will be able to set separate parameters for incremental, full and differential backups.
Another way I prefer is to do this task using a dedicated backup software setup.
Earlier I had MS DPM to manage SQL backups, and it really worked awesomely.
I have also tried Cloudberry backup for SQL servers and it is also a light and reliable cloud based backup tool.
I have a backup from database in SQL Server 2008 R2.
When I want to restore this backup to SQL Server, I get this error:
"Error: Specified cast is not valid. (SqlManagerUI)"
How to I resolve this error?
Thanks.
This would also happen when you are trying to restore a newer version backup in a older SQL database. For example when you try to restore a DB backup that is created in 2012 with 110 compatibility and you are trying to restore it in 2008 R2.
There are some funnies restoring old databases into SQL 2008 via the guy; have you tried doing it via TSQL ?
Use Master
Go
RESTORE DATABASE YourDB
FROM DISK = 'C:\YourBackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:\Data\YourMDFFile.mdf',--check and adjust path
MOVE 'YourLDFLogicalName' TO 'D:\Data\YourLDFFile.ldf'
Sometimes it happens because of the version change like store 2012 db on 2008, so how to check it?
RESTORE VERIFYONLY FROM DISK = N'd:\yourbackup.bak'
if it gives error like:
Msg 3241, Level 16, State 13, Line 2
The media family on device 'd:\alibaba.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Line 2
VERIFY DATABASE is terminating abnormally.
Check it further:
RESTORE HEADERONLY FROM DISK = N'd:\yourbackup.bak'
BackupName is "* INCOMPLETE *",
Position is "1",
other fields are "NULL".
Means either your backup is corrupt or taken from newer version.
I had a similar error "Specified cast is not valid" restoring from SQL Server 2012 to SQL Server 2008 R2
First I got the MDF and LDF Names:
RESTORE FILELISTONLY
FROM DISK = N'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
GO
Second I restored with a MOVE using those names returned:
RESTORE DATABASE Davincis3
FROM DISK = 'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
WITH
MOVE 'JQueryExampleDb' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.mdf',
MOVE 'JQueryExampleDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.ldf',
REPLACE
GO
I have no clue as to the name "JQueryExampleDb", but this worked for me.
Nevertheless, backups (and databases) are not backwards compatible with older versions.
I am using command
db2 restore db S18 from /users/intadm/s18backup/ taken at 20110913113341 on /users/db2inst1/ dbpath on /users/db2inst1/ redirect without rolling forward
to restore database from backup file located in /users/intadm/s18backup/ .
Command execution gives such output:
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
When I'm trying to connect to restored DB (by executing 'db2 connect to S18'), I'm getting this message:
SQL0752N Connecting to a database is not permitted within a logical unit of
work when the CONNECT type 1 setting is in use. SQLSTATE=0A001
When I'm trying to connect to db with db viewer like SQuireL, the error is like:
DB2 SQL Error: SQLCODE=-1119, SQLSTATE=57019, SQLERRMC=S18, DRIVER=3.57.82
which means that 'error occurred during a restore function or a restore is still in progress' (from IBM DB2 manuals)
How can I resolve this and connect to restored database?
UPD: I've executed db2ckbkp on backup file and it did not identified any issues with backup file itself.
without rolling forward can only be used when restoring from an offline backup. Was your backup taken offline? If not, you'll need to use roll forward.
When you do a redirected restore, you are telling DB2 that you want to change the locations of the data files in the database you are restoring.
The first step you show above will execute very quickly.
Normally, after you execute this statement, you would have one or more SET TABLESPACE CONTAINERS to set the new locations of each data file. It's not mandatory to issue these statements, but there's no point in specifying the redirect option in your RESTORE DATABASE command if you're not changing anything.
Then, you would issue the RESTORE DATABASE S18 COMPLETE command, which would actually read the data from the backup image, writing it to the data files.
If you did not execute the RESTORE DATABASE S18 COMPLETE, then your restore process is incomplete and it makes sense that you can't connect to the database.
What I did and what has worked:
Executed:
db2 restore db S18 from /users/intadm/s18backup/ taken at 20110913113341 on /<path with sufficient disk space> dbpath on /<path with sufficient disk space>
I got some warnings before, that some table spaces are not moved. When I specified dbpath to partition with sufficient disk space - warning has disappeared.
After that, as I have an online backup, I issued:
db2 rollforward db S18 to end of logs and complete
That's it! Now I'm able to connect.
How do I write a T-SQL backup database command to specify a file containing spaces?
Here is what I have:
BACKUP DATABASE AMDMetrics TO DISK = 'C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT'
And this is the error I get:
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'C:\Documents and Settings\daultrd\My Documents\DatabaseBackups\AMD_METRICS.DAT'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Try sharing your intended destination folder and using a UNC path to backup from the server to your local machine.
BACKUP DATABASE AMDMetrics
TO DISK = '\\YourMachineName\SharedFolderName\AMD_METRICS.DAT'
This works for me, are you sure that the directory is correct?
backup database master to disk = 'c:\Test Me\master.bak'
Processed 41728 pages for database 'master', file 'master' on file 1.
Processed 5 pages for database 'master', file 'mastlog' on file 1.
BACKUP DATABASE successfully processed 41733 pages
in 22.911 seconds (14.230 MB/sec).
copy and paste this into explorer and see if you can get there C:\Documents and Settings\daultrd\My Documents\DatabaseBackups
This of course has to be the same machine, otherwise you need to map a drive to the location or use UNC paths
I was working through this issue as well.
It's possibly that the Service that SQL Server is running under (Network Service by Default) doesn't have permission to the folder specified.
BACKUP DATABASE master TO DISK = 'master1.bak' WITH INIT
The above should backup to the default backup folder
if that works with no problem it'll be the problem stated.