Solved

SQL 2008

Posted on 2011-02-23
12
345 Views
Last Modified: 2012-06-22
Hei!
      I would like to restore a 250GB database (data Mart) to a development enviroment.
I know u cannot choose tables in Restore ?
 some tables are in a filegroup, and it is absolutely ok that i exclude them?
thanks
0
Comment
Question by:shanj
  • 7
  • 4
12 Comments
 
LVL 6

Expert Comment

by:anushahanna
ID: 34961829
Yes, you cannot choose to restore only a few tables.
(alternative is you can use SSIS Import/Export to just move the tables that you need to the new server; but if you have many servers, it becomes a hassle).

You can do backup restore at
*Database Level
*File/Filegroup level

If your backup is at File Level, then you can restore at File level; if your backup is at database level, then you cannot restore at file level.
0
 
LVL 4

Expert Comment

by:rocky_lotus_newbie
ID: 34961846
Can you elaborate a bit more?
0
 

Author Comment

by:shanj
ID: 34962013
Hello

 i would like to restore a prod. DB to a development enviroment everyday (at midnight) via a script.
It shold include not all tables.

or

how do i retore a DB without taking with me filegroups. ( is it possible)..
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 6

Expert Comment

by:anushahanna
ID: 34964015
can you explain what do you mean by "without taking with me filegroups."

what you will need to do is create a file group and move all the tables you want to move to Dev every night, into that file group. then just backup and restore that filegroup (or filegroups) to dev. Hopefully this will be much smaller than 250 GB and will server your purpose.

The syntax to add a filegroup is

ALTER DATABASE DBName
ADD FILEGROUP FGName;

then you have to add a file to the filegroup.

ALTER DATABASE DBName
ADD FILE
(
NAME = DBName_FG_DATA,
FILENAME = 'C:\DBName\DBName_Data.ndf',
SIZE = 6MB,
MAXSIZE = 180MB,
FILEGROWTH = 1
)TO FILEGROUP FGName;

you can even make the above filegroup your default one:

ALTER DATABASE DBName
  MODIFY FILEGROUP FGName DEFAULT;
0
 
LVL 6

Expert Comment

by:anushahanna
ID: 34964044
once you create your filegroup, then just ship your preferred tables to them:

CREATE UNIQUE CLUSTERED INDEX 'ClustedIndexName' ON TABLENAME(ColName) WITH (DROP_EXISTING = on) ON OVAMS_FG

so the clustered index tables will just move totally from primary group to the filegroup.
0
 
LVL 6

Expert Comment

by:anushahanna
ID: 34964096
commands to backup and restore Filegroups:

BACKUP DATABASE DBName
   FILEGROUP = 'FGName '
   TO DISK = 'C:\MySQLServer\Backups\FGBackup.bak'


RESTORE DATABASE DBName FILEGROUP = 'FGName ' FROM DISK = 'E:\FGBackup.bak'
0
 

Author Comment

by:shanj
ID: 34967688
Hello Anushahanna!

your last comment  :"commands to backup and restore Filegroups"

I tried this but i got a heap of errors fks:
"Directory lookup for the file "D:\DATA\STAGE_T_ORDERS]_1.ndf" failed with the operating system error 2(The system cannot find the file specified.)"

1. The reason is quite obvious, i have taken a whole backup of the DB and then i aam trying to restore
the backup without the given filgroups?

my question
1. HOw do i take backup without the filegroups ( syntax) if possible. and if i take some filegroups?
2 and than i have to restore it)
0
 
LVL 6

Accepted Solution

by:
anushahanna earned 250 total points
ID: 34970119
shanj, the following will work- use caution when you use REPLACE. if possible test in the test box before taking to Dev.

1) This will do a regular backup- it backs up everything
BACKUP DATABASE [STAGE_T_ORDERS] TO  DISK = N'C:\RegFULL.bak' WITH  DESCRIPTION = N'Reg Full', INIT,  NAME = N'STAGE_T_ORDERS-Full Database Backup', STATS = 10
2)This restores what you took in Step #1. When you use replace option, it will just go over what is already in Dev.
RESTORE DATABASE [STAGE_T_ORDERS] FROM  DISK = N'C:\RegFULL.bak' WITH  REPLACE,  STATS = 10
3)This backs up only one File Group, called "STAGE_T_ORDERS_FileGroup_OnlyCertainTables"
BACKUP DATABASE [STAGE_T_ORDERS] FILEGROUP = N'STAGE_T_ORDERS_FileGroup_OnlyCertainTables' TO  DISK = N'c:\FG_Only.bak' WITH INIT,  NAME = N'STAGE_T_ORDERS-Full Filegroup Backup', STATS = 10
4)Now use the backup from Step #3 to replace the filegroup table data only in the desination dev box.
RESTORE DATABASE [STAGE_T_ORDERS] FILE = N'STAGE_T_ORDERS_FileGroup_OnlyCertainTables_DATA' FROM  DISK = N'C:\FG_Only.bak' WITH REPLACE, STATS = 10
0
 

Author Comment

by:shanj
ID: 34977663
Thanks it worked 100%, with a few adjusments.

Bye
0
 
LVL 6

Expert Comment

by:anushahanna
ID: 34982382
glad! Welcome to EE,shanj! Hope you enjoy and benefit here.
0
 
LVL 6

Expert Comment

by:anushahanna
ID: 34982457
to close the question, you can click 'accept as solution'.
0
 

Author Closing Comment

by:shanj
ID: 34998013
v.v.good
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question