Solved

SQL Express 2014 - Script to backup transactions

Posted on 2016-08-30
8
71 Views
Last Modified: 2016-09-05
WE have a SQL Express installation for a product and we need to find a way to backup the logs every 2 hours.
What's the best way to achieve this using?

Thanks.
0
Comment
Question by:BJMagill
  • 4
  • 3
8 Comments
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 41777641
Use scheduled tasks to run a backup script using sqlcmd or PowerShell. See Back Up a Transaction Log (SQL Server).
0
 
LVL 4

Expert Comment

by:Daniel Jones
ID: 41777959
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41778032
@Daniel: SQL Express has no SQL Server Agent who executes scheduled jobs.
0
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.

 

Author Comment

by:BJMagill
ID: 41784377
ste5an, outstanding reply however I'd like to be able to apply a date and time stamp. Not sure how to accomplish this using the Powershell script:

Here's what I have..
Backup-SqlDatabase -ServerInstance uuaesrv01\sqlexpress -Database AstaPP -BackupAction Log

Thanks,
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41784383
How do you invoke it? Do you get any error messages?

btw, does your database run in full or bulk-logged recovery mode?
0
 

Author Comment

by:BJMagill
ID: 41784396
Full mode.....
No error. It just writes the backup file as below:
Details
0
 
LVL 33

Assisted Solution

by:ste5an
ste5an earned 500 total points
ID: 41784565
So you mean by timestamp to add it in the file name?

Use the BackupFile parameter.
0
 

Author Comment

by:BJMagill
ID: 41784594
Yup,

That's the job.

So, for anyone that is interested... here is the finished version.

$currentdate = get-date
$currentdate = $currentdate.ToString('MM-dd-yyyy_hh-mm-ss')
Backup-SqlDatabase -ServerInstance uuaesrv01\sqlexpress -Database AstaPP -BackupAction Log -BackupFile AstaLog$currentdate.log

Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

839 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