Solved

Creating Server Backups

Posted on 2014-10-26
7
139 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
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.

705 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