Solved

Creating Server Backups

Posted on 2014-10-26
7
129 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:
lionelmm 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:lionelmm
ID: 40408226
try
cscript c:\YourScriptName.vb >>Results.Log
and post that log please
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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:lionelmm
lionelmm 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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

Phishing is at the top of most security top 10 efforts you should be pursuing in 2016 and beyond. If you don't have phishing incorporated into your Security Awareness Program yet, now is the time. Phishers, and the scams they use, are only going to …
Stuck in voice control mode on your Amazon Firestick?  Here is how to turn it off!!!
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…
Where to go on the main page to find the job listings. How to apply to a job that you are interested in from the list that is featured on our Careers page.

895 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