Solved

Creating Server Backups

Posted on 2014-10-26
7
130 Views
Last Modified: 2014-11-15
I am trying to move my scheduled tasks from my old server to my new server and I am having difficulty.  Lets start with this:  I want to move my local data backups and my web files to dropbox.  Here is the script that worked on Server 2008 but doesn't appear to be working on Server 2012.  I am assuming it is a security setting?

'Run as administrator
If WScript.Arguments.length = 0 Then
	Set Shell = CreateObject("Shell.Application")
  
	'Pass a bogus argument with leading blank space, say [ uac]
	Shell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
	'Set runtime variables
	Today			= Replace(Date(), "/", "-")
	BackupDest		= "C:\Backup\inetpub\" & Today
	InetPubPath		= "C:\inetpub\h51web\*"
	SQLBakPath		= "C:\data_backups"
	DropBoxPath		= "C:\Users\Administrator\Dropbox\From Server\data_backups"
	Set FSO			= CreateObject("Scripting.FileSystemObject")
	Set SQLBakDir		= FSO.GetFolder(SQLBakPath)
	Set Shell		= WScript.CreateObject("WScript.Shell")

	'If it's Friday do inetpub backup
	If (WeekDay(Now()) = 6) Then
		'Create the folder for today's date, if it does not exist already
		If Not FSO.FolderExists(BackupDest) Then
			FSO.CreateFolder BackupDest
		End If

		'Make a copy of today's inetpub directory
		Shell.Run("xcopy /C /Y /H /E /EXCLUDE:C:\ScheduledTasks\do_backups_exclusions.txt " & InetPubPath & " " & BackupDest)
	End If
		
	'Move all the SQL backup files to the dropbox directory and
	'delete any files whose names conflict (old)
	For Each File in SQLBakDir.Files
		DestFile = DropBoxPath & "\" & File.Name
		
		'Delete the old version if the file already exists
		If FSO.FileExists(DestFile) Then
			FSO.DeleteFile DestFile
		End If
			
		FSO.MoveFile File.Path, DestFile
	Next

	'Clean up any files/directories older than 21 days
	Shell.Run("forfiles /P C:\backup\inetpub /D -21 /C ""cmd /c DEL /F /Q @path""")

	'Unset object variables and quit
	Set Shell		= Nothing
	Set SQLBakDir	= Nothing
	Set FSO			= Nothing
End If
WScript.Quit()

Open in new window

0
Comment
Question by:Bob Schneider
  • 4
  • 3
7 Comments
 
LVL 24

Accepted Solution

by:
Lionel MM earned 500 total points
ID: 40406232
What is happening when you run this script, what error are you getting?
0
 

Author Comment

by:Bob Schneider
ID: 40407702
I am not getting an error...but nothing happens.
0
 
LVL 24

Expert Comment

by:Lionel MM
ID: 40408226
try
cscript c:\YourScriptName.vb >>Results.Log
and post that log please
0
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.

 

Author Comment

by:Bob Schneider
ID: 40417848
I have simplified my task.  My web backups are working fine so all I am left with is my data backups.  Here is what I want to do:
1) Create a full data backup (*.bak) for each of my databases each day to" c:\data_backups".
2) Then every hour I want to create a transaction log backup (*.trn) for each database to the same folder.
3) Every evening I want to copy all the files in my backup folder to my dropbox ("c:\users\administrator\dropbox\data_backups").  
4) I want to keep the backups for one week and then delete them.

Any help would be much appreciated.
0
 

Author Comment

by:Bob Schneider
ID: 40417849
I should also have mentioned that I actually want to "move" the *.bak files to the dropbox location rather than copy them.  I either want to delete the ones on the server hard drive after moving them to the dropbox location or overwrite them with the new backup.
0
 
LVL 24

Assisted Solution

by:Lionel MM
Lionel MM earned 500 total points
ID: 40419427
1) Create a full data backup (*.bak) for each of my databases each day to" c:\data_backups".
2) Then every hour I want to create a transaction log backup (*.trn) for each database to the same folder.
These two tasks are best done through SQL enterprise manager itself--any reason you don't want to do that?
0
 

Author Comment

by:Bob Schneider
ID: 40423870
Because I have sql server express and it doesn't permit that due to the lack of sql agent running.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Originally published Entrepreneur.com Booming numbers of freelancing professionals are changing the face of work. In the United States alone last year, the number of workers freelancing grew from 700,000 to 54 million, according to a Freelancers’…
This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…
Saved searches can save you time by quickly referencing commonly searched terms on any topic. Whether you are looking for questions you can answer or hoping to learn about a specific issue, a saved search can help you get the most out of your time o…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now