I want to restore/import a postgreSQL DB, that i have stored several months ago.
I stored the DB in directory and not in a *.backup file those days.
The directory has lots of files like xxxx.dat.gz, but i can't choose any option like
"from directory" in PGAdmin.
So how can i restore this? isnt there any "restore from directory" option any more?
Related
Not very familiar with databases, but I have a task where an entire database folder was backed up and copied to a drive on my computer. I have SQL Server installed and Microsoft SQL Server opened. How do I use this folder and its contents as a database?
The folder has the following subfolders
SQL Server -> Backup, binn, DATA, FTData, Install, Jobs, Log, Upgrade and two files: sql_engine_core_inst_keyfile.dll, sql_fulltext_keyfile.dll
For each .ldf+.mdf file sets you have you can restore a database using the following sql. You cannot create the databases in bulk and will have to do them one at a time if you have multiple.
For each .ldf + .mdf combo you have update the dbname and the two filenames
create database dbname
on
(
Filename= 'path where you copied .mdf data file',
Filename ='path where you copied .ldf log file'
)
For comparison purposes I'm trying to create two identical databases from one backup. The backup contains only one database.
Creating first database is going well.
When trying to create second database from the same backup file I get the error:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Restore of database 'defaultDB' failed. However, the Tail-Log backup operation completed successfully. (Microsoft.SqlServer.Management.RelationalEngineTasks)
------------------------------
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The file 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\dbname.mdf' cannot be overwritten. It is being used by database 'dbname'. (Microsoft.SqlServer.SmoExtended)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
Do I have to change the mdf and ldf files to a new one?
Simply uncheck the option about "Take tail-log backup before restore" in the Options screen. A tail-log backup is used typically for when you have a log file (LDF) but a corrupt data file (MDF). It does not apply here
In the Files screen, rename the files (or path if you want). Each DB will have it's own MDFs and LDFs. This will rename the files on restore to avoid a conflict
The error comes from point 2, but point 1 applies here too. Doing a log backup each time will give different data in restore because changes (DDL or data) that happen between log backups
Change the path of the destination database i.e create a separate location and store the .mdf and .ldf files there, while creating the second identical database
Restore the identical database overwrite the second(with replace) under options tab
I am trying to restore a database backup but getting error:
Restore failed for Server 'ASIF-VAIO'.
(Microsoft.SqlServer.SmoExtended)
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: File 'C:\Program Files\Microsoft SQL
Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\uwa.mdf' is claimed by
'Aston_Fresh_log'(2) and 'Aston_Fresh'(1). The WITH MOVE clause can be
used to relocate one or more files. (Microsoft.SqlServer.Smo)
When restoring, you need to be sure to
pick a new database name that doesn't already exist (unless you want to overwrite that pre-existing database)
you tick the Overwrite option in the Options tab page and define valid and new file names for the .mdf and .ldf file so that you don't accidentally overwrite another database on your system:
This post has some excellent answers but I don't believe my solution was covered here, or I didn't understand the answer/comment.
However, when I encountered this error I was restoring a database with 2 indexes (Primary and Index). The issue was that when restoring it had created two .ndf files, one for each index, but had named them the same thing.
So essentially I had two "Restore As" files restoring to "D:\MSSQLDATA\DatabaseName.ndf.
To overcome this I had to change one of the file names, so for example I changed
Index | D:\MSSQLDATA\DatabaseName.ndf
Primary | D:\MSSQLDATA\DatabaseName1.ndf
having unique file names fixed this for me.
This worked for me : giving a different name to each MDF and LDF file in the script section.
MOVE N'R_Data'
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Build51_Testing_db1.mdf',
MOVE N'R_audit'
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Build51_Testing_db2.mdf',
etc...
Originally suggested by Alberto Morillo
I know it's long since the last answer, but I happened to search in google for solution for this problem.
What did it for me, was scripting the restore (changing file name did not do the trick) and manually changing the filenames in code
RESTORE DATABASE [DB_NAME]
FILE = N'[name]',
FILE = N'[name1]',
FILE = N'[name2]'
FROM DISK = N'[file_path]'
WITH FILE = 1m
MOVE N'[name]' TO N'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\\[name].mdf',
MOVE N'[name1]' TO N'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\\[name1].mdf',
MOVE N'[name2]' TO N'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\\[name2].mdf',
MOVE N'[logname]' TO N'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data\\[logname].ldf'
NOUNLOAD,
REPLACE,
STATS = 10
GO
Regards
If you have this issue and it's not the above, try under the Restore Options > Files, check the Relocate all files to folder checkbox.
In my case, there was already a .mdf and .ldf file in my \DATA folder, so I had to create two new files:
New-Item C:\path\to\sql\DATA\NewDatabase.mdf
New-Item C:\path\to\sql\DATA\NewDatabase_log.ldf
And then in the SQL manager you need to select those new files when restoring the database.
In my case, the database has 2 mdf files. And the error came, because I'm trying to restore both mdf files as the same name.
Just rename the second mdf file, under "Restore As".
I've got a SQL Server database backup (file extension .bak) from an project of 12 y/a which I tried to restore on SQL Server 2005.
But this gave me an error that it was not the right version..
So I'm trying to find a SQL Server 2000 version to see if I can restore it with this but I can't find any version that works.
Is there another program to save my backup?
Copied over from msdn forums:
1) Go to restore database
2) Select the database that you want to back up to
3) Locate the backup file on disk. You may have to put it into the MSSQL Server -> MSSQL.1-> MSSQL -> Backup Folder. It must be a .bak file.
4) Select the back that want to restore from the available backups.
5) Go to the top left "options" property and when you do that select "overrite existing database".
6) Now make sure that the path to the files on database to be restored are correct in this same dialog view. Look at the paths to the database file and the log file and make damn sure that they are the correct ones for the database to be restored. The problem here is that those paths are going to be for the filesystem that the backup came from, not the one you are goning to put the restore onto.
Just to add to that, if you are restoring a database to a new server that does not have the database already in it (to restore to), create a sham database with the same name, then restore to it with the overwrite settings mentioned above.
I have two backup files
1) is named 'backup.sql' with a bunch of SQL defining TABLES
2) is named 'backup' with a bunch of encoded data, which I believe are the ROWS
I need to restore these TABLES + ROWS, but all I am able to figure out is how to restore the tables.
Any tips on dealing with these files? It's the first time I ever deal with SQL Server.
The backup process would not create a file with actual SQL statements, it would create a binary file. So #1 is not a backup file (it's probably a script someone saved to re-create the schema).
I would try to use SQL Server Management Studio to restore the second file and see what happens. I don't think it will allow you to restore an invalid file, but I would take some basic precautions like backing up the system first.
What is the extension for the 'backup' file? Is the filename backup.bak? If you have a backup file created by sql server then it 'should' contain the logic to create both the tables and restore the data, but it could depend on how the backup was created.
---Edit
It is possible for a .SQL file to contain data values as well as the logic to create the tables/columns for a database. I used to run backups of a MySql database in this way a long time ago...it just is not seen very often with SQL server since it has built in backup/restore funcationality.
Seems unlikely they would export all the rows from all tables into CSV file, and given you said it looks encrypted, it's making me think that's your actual backup file.
try this, save a copy of the "backup" file, rename it to backup.bak and run this from SQL Server Management Studio
restore filelistonly from disk='C:\backup.bak'
(assuming your file is saved on the root of the C: drive)
Any results/errors?