cancel
Showing results for 
Search instead for 
Did you mean: 

SAP SQL Anywhere RESTORE with RENAME - What is the correct script for restoring database

hrrudnytro111
Explorer
0 Kudos
606

Dear Colleagues!
I restored  to new space database SQL Anywhere with RENAME clause pointing out to new dbspace example:

RESTORE DATABASE '/new place/restored.db' FROM '/old place/backup.01'
RENAME extra to '/new place/extra.db' RENAME extra2 to '/new place/extra2.db' RENAME extra3 to '/new place/extra3.db' RENAME msg to '/new place/msg.db'

After restore I'm trying to start new database server and I'm getting error message
I. 01/27 08:57:04. Opening dbspace 'extra' in file '/old_place/extra.db' for database 'verif_test_restored'
I. 01/27 08:57:04. Opening dbspace 'extra2' in file '/old_place/extra2.db' for database 'verif_test_restored'
In other words -> system is looking to old DB Space even-though RENAME clause was used
Can you, please, help me with my problem?

View Entire Topic
chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

Some things to consider

  • you might not want to RESTORE a database on the same server as the source database is currently running.  This could result in a naming conflict. 
  • if you are running a network server, you have to ensure that you have given permissions to start a database with the -gd switch.  I would suggest RESTORE on a personal server to avoid that requirement. 

I would likely use, where ENG is a unique server name on the machine running the restore. This will autostart the personal server.

dbisql -nogui -c "UID=dba;PWD=password;ENG=MyBURestore;DBN=utility_db" /restore_files/restore.sql

hrrudnytro111
Explorer
0 Kudos

Hello, Chris!
Thanks for your answer!
Let me comment your considerations.

Consideration #1. 
That's why I use different naming conventions. I can share my experience that I managed to restore database on similar server while running another database, the only difference was in successful case - there was only one database file. And there is business requirement to implement my use-case, I mean not to stop running database server.
Consideration #2.
It is the same machine. So the requirement is restoring with such set up
Feel free to provide reasons why "a_restore" error message can appear

Thanks!

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

You glossed over the details of the "a_restore" error.  As I noted, this is a temporary connection that is used during the restore. It may be related to some of the usage issues for the RESTORE. I do not think it is critical in explaining the issue.

During the restore process, the SYSTEM dbspace is loaded on the server performing the restore.  If you are already running the "old" SYSTEM dbspace, the restore cannot load the restored SYSTEM dbspace because each database name must be unique and I do not see a way to make that happen with a restore.  I do not think that the SYSTEM dbspace can be renamed during the RESTORE.   Doing so, the error -717 RESTORE unable to open file %1 is reported. You may be able to provide a distinct database name to the source database so that when the restored database is loaded, the database name will not be in conflict. I suspect that you are simply relying on the default naming rules. i.e., dbsrv17 -n MyServ c:\myPath\MyDatase.db will use the default database name which is the file without pathing and extension or in this case MyDatabase.  Instead, you can explicitly name the database dbsrv17 -n MyServ c:\myPath\MyDatabase.db -n MyExplicitDBN.  

I have misspoke as you only need the -gu option as its scope is limited to the utility_db. The -gd defines the rule for any connection. The -gu option is required when running a network server and you want to start a database on it. 

  • I still recommend doing the restore on a separate server, moreso now that the source database must stay running. 
  • If you need to rename the backup system dbspace, that cannot be done with the RESTORE statement.  I would us xp_move_file or something at the OS level to perform that rename.
  • Once the restore is done, you can connect to the utility_db on the server hosting the source database and then use the START DATABASE Statement to start the backup and if needed use the AS to set the database name. 
hrrudnytro111
Explorer
0 Kudos

Hello, Chris!
Thanks for providing the reply

Two comments from my side:
Comment #1.

  • If you need to rename the backup system dbspace, that cannot be done with the RESTORE statement.  I would us xp_move_file or something at the OS level to perform that rename - I don't want to rename "dbspace" I want to map to newly created files with another name

Comment #2. I'm trying to understand what "a_restore" means -> because it looks like this error happens after restore is completed and database server is trying to complete it.
My next steps will be - Stop database server which is running and try to run my restore with changing file names

hrrudnytro111
Explorer
0 Kudos

Hello, Colleagues!
Maybe it makes sense to register my use-case as the valid use-case for the database management, and implement improvement if there is no solution for it.
As I'm following manual and it looks like current version of restore process doesn't support it!
Thanks!
SAP SQL Anywhere 

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

You cannot perform the restore on the same database server where the source database is currently running. You either need to stop the source database -or- run a different engine during the restore. in short, if you are restoring a database from backup, the source database would be expected to be in a bad state and not be running.  There are viable ways to achieve your requirements in the existing implementation, either archive or the more modern image backup methods.