Solved

Creating Server Backups

Posted on 2014-10-26
7
126 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
Comment Utility
What is happening when you run this script, what error are you getting?
0
 

Author Comment

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

Expert Comment

by:lionelmm
Comment Utility
try
cscript c:\YourScriptName.vb >>Results.Log
and post that log please
0
Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

 

Author Comment

by:Bob Schneider
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Because I have sql server express and it doesn't permit that due to the lack of sql agent running.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Finding a job can be stressful - searches, resume tweaks, and networking events can be super boring. Luckily we're here to help you land your dream job!
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…

763 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

10 Experts available now in Live!

Get 1:1 Help Now