Solved

Creating Server Backups

Posted on 2014-10-26
7
135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 25

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 25

Expert Comment

by:Lionel MM
ID: 40408226
try
cscript c:\YourScriptName.vb >>Results.Log
and post that log please
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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 25

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Stuck in voice control mode on your Amazon Firestick?  Here is how to turn it off!!!
Gift cards are not a new concept - it's been around for a very long time.  Undoubtedly, over the past you have received such a card or purchased one for a friend or relative.  Are you aware that you've been feeding the machine?  If not, read on :)
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…
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.

739 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