Selasa, 16 September 2014

[MS_AccessPros] Re: How to Make Menu Backup and Restore

 

Bill,

I use Windows task scheduler (Win 7) to perform auto backups.  Here is a .vbs script that I call from the task scheduler (Note:  I copied this from a friend, I didn't write it):

 

'This script will copy the database from its normal folder, to a backup folder.  The copy

' gets a name change to DatabaseDmmddyyPM.accdb short date with a AM or PM tagged ' on end). I use Task scheduler to fire this code once a week or as needed.

dim strFrom, strTo, strNow, strMonth, strDay, strYear, strAmPm, fso

set fso = CreateObject("Scripting.FileSystemObject")

'Path and file name of source, use the full server address not a mapped drive

strFrom = "\\myservername\mydatabase.accdb"

' As the Now function will make a single character day and/or'Month if those happen to be single characters.  We want to force this to two

'characters always.  Unfortunately VBS has no Format function like straight VB'so we must jump thru hoops to make it happen.  To differentiate between the two'times of copy of the day we attach the last two characters of Now (AM or PM)'on to the end

strMonth = Month(Now)

if len(trim(strMonth)) < 2 then strMonth = "0" & strMonth

strDay = Day(Now)

if len(trim(strDay)) < 2 then strDay = "0" & strDay

strYear = Year(Now)

strAmPm = right(now,2)

strDateTag = strMonth & strDay & strYear & strAmPm

'msgbox strDateTag

'Path and file name of destination

strTo = "\\mybackupservername\mydatabasename " & strDateTag & ".accdb"

'msgbox strTofso.CopyFile strFrom, strTo

set fso = nothing

John F

 


 

__._,_.___

Posted by: jfakes@rocketmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

.

__,_._,___

Tidak ada komentar:

Posting Komentar