daily backup backend database

S

Song

I plan to use DOS batch file to create a copy of backend database
daily with date:

mydata will be copied as
mydata20100329

And I can put that batch file in Windows scheduler to run daily.

What's the DOS syntax?
 
A

Arvin Meyer [MVP]

Copy source destination

is your syntax, and it should work from a batch file run in scheduler.

Also look at xcopy
 
P

Paul Shapiro

The copy may be corrupt if anyone has the database open at the time you make
the copy. You can add a line to check that the .ldb file does not exist
before making the copy. This is an example from a command file a user runs
interactively to make a local copy of the backend data, but you could adjust
it for your scheduled task:

@echo off

REM Cannot make a valid copy while database is in use
if Exist \\MyServer\MyShare\MyBackendData.ldb Goto DatabaseInUse

REM Create the backup folder in case it does not already exist.
mkdir C:\DBBackup
copy "\\MyServer\MyShare\MyBackendData.mdb" "C:\DBBackup\"

REM Let the user see the results. NOTE: Do NOT do this in a scheduled task.
pause
exit

:DatabaseInUse
echo ERROR: Cannot copy database file while program is being used.
pause
exit
 
S

Song

The copy may be corrupt if anyone has the database open at the time you make
the copy. You can add a line to check that the .ldb file does not exist
before making the copy. This is an example from a command file a user runs
interactively to make a local copy of the backend data, but you could adjust
it for your scheduled task:

@echo off

REM Cannot make a valid copy while database is in use
if Exist \\MyServer\MyShare\MyBackendData.ldb Goto DatabaseInUse

REM Create the backup folder in case it does not already exist.
mkdir C:\DBBackup
copy "\\MyServer\MyShare\MyBackendData.mdb" "C:\DBBackup\"

REM Let the user see the results. NOTE: Do NOT do this in a scheduled task.
pause
exit

:DatabaseInUse
echo ERROR: Cannot copy database file while program is being used.
pause
exit










- Show quoted text -

Thanks, but that does not add current date to mydata.mdb If I run
today, the copied one should be mydata20100329.mdb so I can keep many
version of files until I manually delete them.
 
D

Douglas J. Steele

So change

copy "\\MyServer\MyShare\MyBackendData.mdb" "C:\DBBackup\"

to

copy "\\MyServer\MyShare\MyBackendData.mdb" "C:\DBBackup\MyData" &
Format(Date, "yyyymmdd") & ".mdb"


--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

The copy may be corrupt if anyone has the database open at the time you
make
the copy. You can add a line to check that the .ldb file does not exist
before making the copy. This is an example from a command file a user runs
interactively to make a local copy of the backend data, but you could
adjust
it for your scheduled task:

@echo off

REM Cannot make a valid copy while database is in use
if Exist \\MyServer\MyShare\MyBackendData.ldb Goto DatabaseInUse

REM Create the backup folder in case it does not already exist.
mkdir C:\DBBackup
copy "\\MyServer\MyShare\MyBackendData.mdb" "C:\DBBackup\"

REM Let the user see the results. NOTE: Do NOT do this in a scheduled
task.
pause
exit

:DatabaseInUse
echo ERROR: Cannot copy database file while program is being used.
pause
exit
- Show quoted text -

Thanks, but that does not add current date to mydata.mdb If I run
today, the copied one should be mydata20100329.mdb so I can keep many
version of files until I manually delete them.
 
T

Tony Toews [MVP]

Song said:
I plan to use DOS batch file to create a copy of backend database
daily with date:

Or you can do it from VBA. Whenever the last person exits the front
end database.

When the user exits the FE attempt to rename the backend MDB
preferably with todays date in the name in yyyy-mm-dd format. Ensure
you close all bound forms, including hidden forms, and reports before
doing this. If you get an error message, oops, its busy so don't
bother. If it is successful then compact it back.

See my Backup, do you trust the users or sysadmins? tips page for more
info.
http://www.granite.ab.ca/access/backup.htm

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 
S

Song

Or you can do it from VBA.  Whenever the last person exits the front
end database.

When the user exits the FE attempt to rename the backend MDB
preferably with todays date in the name in yyyy-mm-dd format.  Ensure
you close all bound forms, including hidden forms, and reports before
doing this.   If you get an error message, oops, its busy so don't
bother.  If it is successful then compact it back.  

See my Backup, do you trust the users or sysadmins? tips page for more
info.http://www.granite.ab.ca/access/backup.htm

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages -http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated seehttp://www.autofeupdater.com/
Granite Fleet Managerhttp://www.granitefleet.com/

I found a solution using 7za, to zip your files with a date at end of
your file name. I put following line in a batch file and put in
Windows scheduler to run every night after veryone exit the
application:

7za.exe a s:\archive\backenddata%DATE:~-8,4%%DATE:~0,2%%DATE:~3,2%.7z
s:\apps\backenddata.accdb

7za is a free utility. Just google it.
 
T

Tony Toews [MVP]

Song said:
I found a solution using 7za, to zip your files with a date at end of
your file name. I put following line in a batch file and put in
Windows scheduler to run every night after veryone exit the
application:

7za.exe a s:\archive\backenddata%DATE:~-8,4%%DATE:~0,2%%DATE:~3,2%.7z
s:\apps\backenddata.accdb

7za is a free utility. Just google it.

I prefer using the free open source Infozip DLLs. It's usually a lot
easier to distribute a few DLLs in the same folder as the FE than it
is to ask the users to install a program.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 
R

Risse

"Song" <[email protected]> kirjoitti
viestissä:bb39b014-a73e-4daf-9572-ff4bf40d2461@u31g2000yqb.googlegroups.com...
Or you can do it from VBA. Whenever the last person exits the front
end database.

When the user exits the FE attempt to rename the backend MDB
preferably with todays date in the name in yyyy-mm-dd format. Ensure
you close all bound forms, including hidden forms, and reports before
doing this. If you get an error message, oops, its busy so don't
bother. If it is successful then compact it back.

See my Backup, do you trust the users or sysadmins? tips page for more
info.http://www.granite.ab.ca/access/backup.htm

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages -http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated seehttp://www.autofeupdater.com/
Granite Fleet Managerhttp://www.granitefleet.com/

I found a solution using 7za, to zip your files with a date at end of
your file name. I put following line in a batch file and put in
Windows scheduler to run every night after veryone exit the
application:

7za.exe a s:\archive\backenddata%DATE:~-8,4%%DATE:~0,2%%DATE:~3,2%.7z
s:\apps\backenddata.accdb

7za is a free utility. Just google it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top