Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

copy mdf and ldf files

Posted on 2015-01-26
7
243 Views
Last Modified: 2015-01-26
proper and safe way to copy ldf and mdf files.

sql server is the rdbms

is it safe for me to stop the sql service and then copy the mdf files or ldf files.
or do i have to detach or brind the db's offline to make this a safe process.

i need to copy the mdf and ldf files on a instance but i can't use the backup service for this.
it needs to be a copy and paste job.

also, dumb question but thought i would check my bases.
making a copy of the mdf and ldf files is just as good as making a full copy only backup of a database correct.

thanks a bunch
0
Comment
Question by:jamesmetcalf74
  • 4
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40570687
is it safe for me to stop the sql service and then copy the mdf files or ldf files.
Yes but stopping SQL Service would make any database in that instance to be unavailable. Also could stop any running process and so with impact in any application.

or do i have to detach or brind the db's offline to make this a safe process.
Safe just because it's only makes a single database offline. Be careful with what I said above about the running processes. The same applies here for the processes relative to the database.

i need to copy the mdf and ldf files on a instance but i can't use the backup service for this.
Why not?
0
 

Author Comment

by:jamesmetcalf74
ID: 40570696
because the sql agent won't start and the server seems jacked up.  Wanted to make some copies of the databases before I dug into the problem.  windows event log won't start either
0
 

Author Closing Comment

by:jamesmetcalf74
ID: 40570697
Thanks Vitor!
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 48

Expert Comment

by:Vitor Montalvão
ID: 40570704
You can run a backup from SSMS. Just create a new query and run the following command:
BACKUP DATABASE DatabaseName TO DISK='<Path\Filename.bak>'

Open in new window

0
 

Author Comment

by:jamesmetcalf74
ID: 40570710
sweet
so the backup utility within sql server does not necessarily rely on sql agent being started?
0
 

Author Comment

by:jamesmetcalf74
ID: 40570713
also... command to run backup for all databases without having to name every one?
0
 
LVL 48

Expert Comment

by:Vitor Montalvão
ID: 40570735
There's no backup utility in SQL Server, only the backup command.
SQL Server Agent is only a schedule task for SQL Server. What it does for backups is run the same backup command in a configured schedule.

Try the following command for backing up all databases (I didn't test it):
exec Sp_MSForEachDB 'BACKUP DATABASE ? TO DISK='C:\temp\?.bak''

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…

840 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