I have a DB2 10 database backup file that I would like to restore to another environment. The problem is that the database has been setup with a different name and the restore complains because the database names are different.
Is there a way to restore the database backup file to the other environment?
Thanks
Here is the command I used to restore:
db2 "RESTORE DATABASE <restore database name> FROM <current restore directory> TAKEN AT <timestamp of full backup> TO <Local database directory> INTO <new database name>"
Example:
Database name of original backup is:
SYSTEM
My backup directory is:
/db2inst1/archive/backup/SYSTEM/level0/
Timestamp of original backup is:
20180503141925
Local database directory is: I would redirect this directory to your database standard list
New database name is:
SYSTEM2
Example output command is:
db2 "RESTORE DATABASE system FROM /db2inst1/archive/backup/SYSTEM/level0/ TAKEN AT
20180503141925 TO /db2inst1/ INTO system2"
Once complete roll-forward database:
db2 "ROLLFORWARD DB SYSTEM2 TO END OF LOGS AND COMPLETE"
You can use the "redirected" restore option by generating a file
db2 restore database mydb redirect generate script restore.sql
Once the script is generated, you can change the names, file locations, etc.
And finally, execute the script
db2 -tvf restore.sql
Thanks for the help.
In the end we dropped the existing database, restored the database from the backup file and then renamed the restored database to match the previous database name
Related
I have database backup A.bak
I want to restore that backup file, using the SQL Server Management Studio, into database B which has all the same tables/columns but just different name.
If I try to do the restore - I am getting error:
The backup set holds a backup of a database other than the existing
How can I resolve this? I tried renaming the .bak file but it didn't work
Specify the "Overwrite the existing database (WITH REPLACE)" option:
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.
I am trying to restore db from my db backup file when i select and add the db .bak file
I have seen that error "No back upset selected to be restored"
I also tried from script to restore it but failed.
kindly tell me some effective way to do that??
I have already tried this but failed
RESTORE DATABASE <Your Database>
FROM DISK='<the path to your backup file>\<Your Database>.bak'
Try RESTORE HEADERONLY to see if there are several backup sets in your bak file
RESTORE HEADERONLY
FROM DISK='<the path to your backup file>\<Your Database>.bak'
http://msdn.microsoft.com/en-us/library/ms178536.aspx
and if there are several sets, choose the one you want :
RESTORE DATABASE <Your Database>
FROM DISK='<the path to your backup file>\<Your Database>.bak'
WITH FILE = <you set number>;
I need to make clean database template backup and then generate a new one database with another name, but with backuped content.
Backup script is:
sqlcmd -S %DB_HOST% -Q "BACKUP DATABASE %DB_NAME% TO DISK = '%BACKUP_FILE%'"
Restore script is:
sqlcmd -S %DB_HOST% -Q "RESTORE DATABASE %DB_NAME% FROM DISK = '%BACKUP_FILE%' WITH REPLACE"
And it works on the same database name.
But if i backup DB 'ORIGINAL_DB_NAME' and then restore it to 'NEW_DB_NAME' it will raise exception:
Msg 1834, Level 16, State 1, Server <HOST>, Line 1
The file '.....\MSSQL\Data\ORIGINAL_DB_NAME.mdf' cannot be overwritten. It is being used by database 'ORIGINAL_DB_NAME'.
....
You need to specify a new location for the data/log files.
See this MSDN article, Example D
RESTORE DATABASE AdventureWorks2012
FROM AdventureWorksBackups
WITH NORECOVERY,
MOVE 'AdventureWorks2012_Data' TO
'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf',
MOVE 'AdventureWorks2012_Log'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf';
RESTORE LOG AdventureWorks2012
FROM AdventureWorksBackups
WITH RECOVERY;
You can also avoid that conundrum using SSMS. Under the Options tab, after you have selected a source for your restore direct the data and log files to either the files you want to overwrite, or point them to the directory you need and name them appropriately.
If you go to Files on the Restore Configuration, make sure that the Original File Name is not the same as Restore As, that should solve your issue.
I have a backup file from my main DB(IDTDB) that called MainDBBackup.bak and i want to restore it with another name.but i recieve this error:
"the logical file 'IDTDB_Log' is not part of database 'newDB'.use RESTORE FILELISTONLY to list logical file names.restore database terminated abnormally.change database context to master."
i used this code to restore my database:
"use master;restore filelistonly from disk=N'my backup file path'; restore database newDB from disk=N'my backup file path' with file=1,replace,nounload,stats=10;"
note: it is important for me to have a new database with new name.
i have created a new database and its tables by execute a sql query and tried to restore my mainDB to it but i recieved that error again.
Using SSMS you can create a new database and then restore to that from your backup. You will need to set the option overwrite existing database.