Cannot Restore from Backup File to Sybase - sybase

We have a very old sybase server. Our database in it is acting up. We need to restore the backup database file from our backup sybase server. But when I try that, I keep getting this error message:
Msg 7205, Level 17, State 2: Line 1: Can't open a connection to site
'SYB_BACKUP'. See the error log file in the SQL Server boot
directory.
That is how I restore the database backup:
1. Use RCP to copy the dump file from the spare server to the primary server. And name the copy "frombkup_mydb.dump".
2. Drop the old database from the primary server, and re-create an empty one.
3. Then use the following command to load the database from the backup dump file:
load database mydb from "/export/home/syb11.dump/frombkup_mydb.dump"
Unfortunately I don't know where the error log file is. I am not familiar with SCO Unix and Sybase.
Does anyone know why the restore doesn't work?
Please help. Thanks.
Jay Chan

It's likely that your Backup Server is not running.
The SAP/Sybase ASE database process requires the backup server to be running for database backups or restores.
To find which database processes are running you can use the showserver command usually located in:
$SYBASE/$SYBASE_ASE/install/showserver
If the backup server is not running (likely), then in the ./install/ directory, look for the file named RUN_SYB_BACKUP
You can start the server by issuing the command (from the ./install/ directory)
startserver -f RUN_SYB_BACKUP
This should start the backup server, and allow you to restore the database.

Related

Different behavior of sql server SSMS vs ODBC for BACKUP DATABASE

I use Sql server Native client 11 for database programing. I use this command to create a full backup
BACKUP DATABASE [AminDB] TO DISK = 'E:\AminExe\Hogug02\BKUP\PYBKUPyy-13970515-1211-1.BAK' WITH INIT, COMPRESSION, NOSKIP;
When I execute this command in SSMS, I get this result:
Processed 175632 pages for database 'AminDB', file 'AminDB_dat' on file 1.
Processed 2 pages for database 'AminDB', file 'AminDB_log' on file 1.
BACKUP DATABASE successfully processed 175634 pages in 6.029 seconds (227.588 MB/sec).
When I execute this command using SqlExecDirect, I get SUCCESS_WITH_INFO and SQLGetDiagRec returns this result:
Processed 175632 pages for database 'AminDB', file 'AminDB_dat' on file 1.
and backup is not created.
for many other databases, executing backup database command always returns SQL_SUCCESS_WITH_INFO, but the backup file randomly is created or not.
What should I do for my Application create successful backup?
thanks in advance
mr.abzadeh
I called SQLMoreResults after BACKUP DATABASE statement repeatedly until it returned SQL_NO_DATA. This completely solved the problem.

How to restore sybase (SAP ASE) .db and .log backup on a another system?

How can I restore (or read in a some decent form) a sybase backup that I've been given to be analyzed?
I have been given a backup from sybase database that contains a single .db and one .log file.
I'm new to sybase and I have no access to original system nor I have any information about the database structure that these files contain.
The thing I know is that backup is probably made with command
dbbackup -c "userid=xxx;password=xxx" -d -t -y D:\path\to\backup
I've been asked to analyze the content of the database and to do that I've set up a SAP ASE 16.0 on RedHat 7.
I have tried to restore the backup using the load database command but all I get is a error report:
Backup Server session id is: 17. Use this value when executing the
'sp_volchanged' system stored procedure after fulfilling any volume change
request from the Backup Server.
Backup Server: 4.10.2.1: Label validation error: first label not VOL1.
Backup Server: 6.31.2.4: Volume rejected.
Backup Server: 1.14.2.2: Unrecoverable I/O or volume error. This DUMP or LOAD
session must exit.
Backup Server: 6.32.2.3: /data/sybase/backup/adbname.db: volume not valid
or not requested (server: , session id: 17.)
Backup Server: 1.14.2.4: Unrecoverable I/O or volume error. This DUMP or LOAD
session must exit.
Msg 8009, Level 16, State 1:
Server 'ASE1', Line 1:
Error encountered by Backup Server. Please refer to Backup Server messages for
details.
the error indicates that the database backup file is not valid.
Are you sure that it is a Sybase ASE dump file. ".db" files look like more DB2 backup files than ASE backup files?
First, you didn't write the restore command for restoring dB and I think you used wrong command for getting backup.
Briefly, for getting backup of a Sybase db you have to write:
create backup
go
Backup files are stored in da\server\instance\dasd\backup\unique_backup_id .
And for load it you have to write:
restore backup "unique_backup_id"
go
If restore backup succeeds, the server automatically shuts down; you must manually restart it.
Resources is: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1570/html/commands/X16531.htm

Restoring SQL2012 to LocalDb

I am trying to restore a *.bak file from a SQL 2012 DB and am having a lot of trouble. There appears to be similar questions that are unanswered so I'm hoping the below elaborates on the issue.
Use the below to get the logical names for the database and log
RESTORE FILELISTONLY
FROM disk = 'C:\Users\jonathan\Desktop\mydb_Full.bak'
Run the below to restore
RESTORE DATABASE mydb
FROM disk = 'C:\Users\jonathan\Desktop\mydb_Full.bak'
WITH RECOVERY,
MOVE 'mydb' TO
'C:\Users\jonathan\mydb.mdf',
MOVE 'mydb_log'
TO 'C:\Users\jonathan\mydb_log.ldf'
Get the error:
Processed 448 pages for database 'mydb', file 'mydb' on file 1.
Processed 2 pages for database 'mydb', file 'mydb_log' on file 1.
Msg 1853, Level 16, State 1, Line 5
The logical database file 'mydb_log' cannot be found. Specify the full path for the file.
Msg 3167, Level 16, State 1, Line 5
RESTORE could not start database 'mydb'.
Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.
Suggestion from SO/Google is to try and detach then attach, the attach may initiate a upgrade process of some sort.
exec sp_detach_db mydb, 'true'
Error:
Msg 3707, Level 16, State 2, Line 17
Cannot detach a suspect or recovery pending database. It must be repaired or dropped.
Blogs suggest setting it to emergency mode:
ALTER DATABASE smsr4000 SET EMERGENCY;
This results in
Msg 823, Level 24, State 1, Line 20
The operating system returned error 5(Access is denied.) to SQL Server during a read at offset 0x00000000012000 in file 'C:\Users\jonathanchannon\mydb.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
So now I'm lost. How can I get this sql backup into LocalDB?
Thanks
UPDATE: There is an open MS issue here on connect and this blog post also look promising but when using sqlcmd to connect to an instance I get and error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2].
UPDATE 2: Finally gave up and installed SQL Express and Management Studio, worked first time.
I ran into the same issue when trying to script our use of LocalDB. However, there is one small detail that got me out of this rut.
First, you should attempt to restore the database and supply the new filenames (using the command RESTORE DATABASE mydb... ). After this, the correct MDF and LDF are mysteriously available in the proper location, despite the error.
After this, you have a few options. The first problem is that SQL will show the database stuck in a "Restoring..." state. This could be solved a few ways, probably. In my solution, I delete and recreate my LocalDB instance using the SqlLocalDb utility. If that's too heavy-handed, you could probably copy the MDF and LDF files, then drop the database instead. This command line stops, drops, and recreates the LocalDB instance named "v11.0":
sqllocaldb p v11.0 && sqllocaldb d v11.0 && sqllocaldb c v11.0 -s
At that point, I had an MDF and LDF that I could use. So, I used this to force it across the finish line:
CREATE DATABASE X ON (Name=X, Filename=X) LOG ON (Name=X, Filename=X) FOR ATTACH;
I ran into a similar issue and did the following to resolve it.
Steps I took:
restore from the backup (BAK) file to localdb
see where the mdf and ldf files went to (probably went to c:\users\yourid)
create new folders in a new area like C:\sql-data-files\data and C:\sql-data-files\log
copy the mdf to the data folder and ldf to the log folder
delete the new database that just appeared in your Databases list as a result of the above restore
then run this script in SQL Server Management Studio
CREATE DATABASE MyDatabase
ON (FILENAME = 'C:\sql-data-files\data\MyDatabase.mdf'),
(FILENAME = 'C:\sql-data-files\log\MyDatabase.ldf')
FOR ATTACH;
All of the above permitted me to bypass the many steps other sites were recommending.

SQL Server 2008 Backup fails: BACKUP DATABASE is terminating abnormally

I have a stored procedure, which performs a database backup for a specific database.
The problem is, it does work on one server and does not work on another server (the servers are on different machines). The backup drive is a local drive of the server.
On the second server I get the exception "BACKUP DATABASE is terminating abnormally."
In the log file there are the following informations:
... Error: 18204, Severity: 16, State: 1.
... BackupDiskFile::CreateMedia: Backup device 'D:\XXX.bak' failed to create. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
... Error: 3041, Severity: 16, State: 1.
... BACKUP failed to complete the command BACKUP DATABASE XXX. Check the backup application log for detailed messages.
What could be the reason for that and where can I find the mentioned backup application log?
Same problem for me
Solution :
→ Not working
C:\
D:\
... or Any Directory
Code:
BACKUP DATABASE [ERP] TO DISK ='C:\ERP.bak'
BACKUP DATABASE [ERP] TO DISK ='D:\ERP.bak'
BACKUP DATABASE [ERP] TO DISK ='E:\ERP.bak'
Will not work!
→ Working
BUT
Code :
BACKUP DATABASE [ERP] TO DISK ='C:\AtleastOneDir\ERP.bak'
BACKUP DATABASE [ERP] TO DISK ='D:\AtleastOneDir\ERP.bak'
BACKUP DATABASE [ERP] TO DISK ='E:\AtleastOneDir\ERP.bak'
Will work for me!
Sounds like a permission problem.
Do you try to backup to a network drive?
Does the drive D: really exist?
What does the Eventlog tell you? Try the Applicationlog in the Eventlog -> eventvwr.msc
It's just a start...
Try to compile the SP again with "with execute as caller" and run it again.
OK. Encountered the same error in my back up too. The user creating back up had admin privileges on the server too. Make sure that the sub folder exists if not create it manually & run it. For Ex. D:\MsSQL\Backup\MyDB\mydb.bak , make sure that myDB folder exists
This answer covers the same error message, but has nothing to with machine-to-machine access permissions - posted it as a reference in case anyone else ends up here searching for the same error codes.
Ran into the same general error message (Error: 3041, Severity: 16, State: 1.) while testing scheduled automated database backups in SQL Server 2008 . Turns out I was using a feature not available in the standard version of SQL Server 2008 - backup compression. Running the generated T-SQL from my custom database backup maintenance plan task (made available through the "View T-SQL" button) got me more detailed information.
Msg 1844, Level 16, State 1, Line 1
BACKUP DATABASE WITH COMPRESSION is not supported on Standard Edition (64-bit).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Changing "Set backup compression" from "Use the default server setting" to "Compress backup" broke the backup script. Changing it back fixed it.
In my case, I restart the SQL Server Service, and now I can make backup like previus.
Try to create windows login on sql server and map it to a windows user that have write permission on the D drive and make sure that the procedure runs under the security context of this user.

How to create a "copy" of SQL Server transaction log file

I want a copy of SQL Server transaction log file for "raw" analysis. What is the safest way to get a copy of that file without shutting down the database and disturbing the existing log/backups/backup schedules and just about everything.
FYI, Its a SQL Server 2000 database server and I can see the log file (its about 4GB in size) and I cannot copy it as is; I get the "access denied" error when copying from explorer or command line.
Can you not analyse the log file backups instead of the log file itself? If you must have a copy of the log file itself, restoring a backup of the database and all transaction logs will give you a replica of the transaction log file in a different database.
You cannot create a copy of a transaction log file, Although, you can create the backup of your database and restore it in another location with another name and then you can detach it.

Resources