SQL Express 2014 - Script to backup transactions

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.
LVL 1
BJMagillAsked:
Who is Participating?
 
ste5anConnect With a Mentor Senior DeveloperCommented:
Use scheduled tasks to run a backup script using sqlcmd or PowerShell. See Back Up a Transaction Log (SQL Server).
0
 
ste5anSenior DeveloperCommented:
@Daniel: SQL Express has no SQL Server Agent who executes scheduled jobs.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
BJMagillAuthor Commented:
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
 
ste5anSenior DeveloperCommented:
How do you invoke it? Do you get any error messages?

btw, does your database run in full or bulk-logged recovery mode?
0
 
BJMagillAuthor Commented:
Full mode.....
No error. It just writes the backup file as below:
Details
0
 
ste5anConnect With a Mentor Senior DeveloperCommented:
So you mean by timestamp to add it in the file name?

Use the BackupFile parameter.
0
 
BJMagillAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.