Save on a different DataBase (1 Viewer)

ilanray

Member
Local time
Today, 09:31
Joined
Jan 3, 2023
Messages
116
Hi
I have a form that insert and update some tables. I would like to insert and update to more than 1 database for backup purposes
I don't want to create a scheduler that copy the database to another folder since I am working in a big company and it takes to much to do it
is there a way to do it?
 

GPGeorge

Grover Park George
Local time
Yesterday, 23:31
Joined
Nov 25, 2004
Messages
1,867
Each transaction would be duplicated in a second accdb as your users work?
 

ilanray

Member
Local time
Today, 09:31
Joined
Jan 3, 2023
Messages
116
currently not but that's what i was thinking about
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:31
Joined
Sep 21, 2011
Messages
14,299
Can't you link to that other DB?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:31
Joined
Feb 19, 2013
Messages
16,612
There are three basic actions - append, update and delete. You would need routines for each of these. Simplistically the impact will be the users will take twice as long to complete an action, perhaps longer.

you might be better off reviewing log processes using data macro’s (assuming you are using access back ends) to log each action on a field by field basis. If your data needs reconstruction you can do so from the log. The log table can be in a separate database and linked in the same way as you (presumably) currently link.

whichever way you decide to go, make sure you keep an open link to the backup database otherwise peril be even slower for the user
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:31
Joined
Jan 23, 2006
Messages
15,379
How many concurrent users are there? Is this all MS Access (FE & BE)?
What is the ultimate goal of a second data base?
Have you considered daily backups as an option?
 

ilanray

Member
Local time
Today, 09:31
Joined
Jan 3, 2023
Messages
116
there are about 40 concurrent users and the ms-access is split database (FE & BE)
The goal of the second database is just for backup incase something will happend. and as I saidI don't want to use daily backup since if the database currepted and I will not notince on time it will overide the correct database

As for the other questions, that's what I was asking about. How to create DOCMD.RUNSQL"insert...." to two DB? or is there another way to backup a table on every transaction to another database
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:31
Joined
Feb 19, 2013
Messages
16,612
You wouldn’t use docmd.runsql. You would use

currentdb. Execute
Or
Db.execute

depending on how you have set things up
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:31
Joined
Feb 19, 2002
Messages
43,275
and as I saidI don't want to use daily backup since if the database currepted and I will not notince on time it will overide the correct database
Then your company's backups are not scheduled correctly. Backups don't overlay each other AND they are kept for rational periods. Such as daily backups are kept for 15 days. Monthly backups are kept for 13 months. Annual backups are kept for 7 years and always off-site. Copies of the more frequent backups are also frequently stored off-site or in the cloud. You don't want the only backup to be in the cloud. It is too time consuming to download and reinstall. You always want the most recent backups to be local or in both places.

You need to get both the FE and the BE onto a rational backup plan so you need to work with your IT people. Data is a company asset. It is THEIR job to protect it. Not yours. You don't have the authority to create actual backups that get stored off-site etc.

Look at the log solutions. Add the log table to a separate BE, preferably on a different server from the normal BE. Link to the log table and use the suggested code to log changes to that linked log table if you want something closer in time to the corruption


BTW, BE's very rarely corrupt. It is the FE that tends to corrupt and that is because of all the changes to the same object. So, make sure when you are developing that you compile before you test any new code and you close and backup the front end frequently during the day. On a heavy coding day, I might end up with 6-10 FE backups. I keep them for a week and then get rid of them. Backups are always named with the name of the FE followed by _yyyymmdd_seqNum so they are always easy to locate and are easily sorted to avoid confusion.
 

GPGeorge

Grover Park George
Local time
Yesterday, 23:31
Joined
Nov 25, 2004
Messages
1,867
Each transaction is duplicated. If you have bound forms, then this becomes significantly more complicated. Bound forms save each addition, modification and deletion to the table as they occur. To duplicate that, you have to add VBA that runs immediately afterwards against the "backup tables". It seems like the effort is doable, but rather daunting.

In the After_Update event of each bound form, you'll have to capture the Primary Key of the changed record and use it to run the appropriate query to copy that change to the "backup table".
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:31
Joined
Feb 28, 2001
Messages
27,186
I'm with Pat on this one. If your big company makes it difficult for you to do backups via some scheduler task, they are big enough to have an IT department. Find out their operations policy regarding backup retention. I can't believe they wouldn't have a tape "leap-frog" method of keeping data for more than just a day or two.

You are worried that you won't notice corruption. So... take action to reduce the odds of corruption. You already started down that path by having a split FE/BE pair of files. Next question: Does each user have a private FE file that is a copy of your "Master FE" file? Because that is the next big step in avoiding corruption.

By the way... it is good that the company wouldn't allow you to "roll your own" backup. Using a scheduler + automated file-copy doesn't help much. It's as much of a gamble because basically, the file-copy is a snapshot of the file in question REGARDLESS of the state of any Access actions that might be underway. It is therefore a snapshot of something that is moving and therefore could be a blurred snapshot because you caught it between parts of a long update. To YOU, it looks like a single update. To Access, it is broken up into as many disk I/O operations as it takes to touch every record in the target table.

BUT... what YOU described - making a shadow transaction behind every insert, delete, or update - is ALSO a snapshot in a different sense. If you do this within the FE, then you have people all over the place doing SQL actions to two files - but of necessity, they are time-sequential actions, not parallel actions, because Access is not multi-threaded. With extremely rare and complex exceptions that involve complex API calls, you can only ask Access to do one SQL action as a time if the BE is native Access (as opposed to something like SQL server). Which means that if ANY user's machine bites the dust between the "live" update and the "backup" update, you STILL have an imperfect snapshot. If you tried to do this using a Data Macro, then you simply transferred the possible origin of corruption from an incomplete FE action to an incomplete BE backup action.

Not only that... if your company invests in an automatic dynamic backup system that keeps driver-level duplication of all disk I/O, then if you DO get corruption, you just replicated it. "Cloud" backups are no help because the cloud protocols tend to get in the way of Access operations. Full-blown replication of all disk actions doesn't help this specific case because it also propagates that putative corruption.

My advice to you is to contemplate the Serenity prayer and then CAREFULLY look at things you CAN do to help the situation. But rolling your own backup isn't as likely to be helpful as you might think.

Before you ask, I was with the U.S. Navy as a contractor during the time that they initiated a COOP initiative. (Continuity Of Operations Program... COOP.) I watched - and participated when allowed to do so - as they analyzed all of these issues. In our case, it was an ORACLE back-end and a package called SmartStar on the front-end, which was a timesharing interactive+batch mainframe. (Or so the Navy considered it.) But we went through analysis to the point that we were as blue in the face as the Navy's Dress Blues. COOP is an exercise in the possible tempered by patience regarding that which cannot be achieved, and doing due diligence to learn which is which.

If you REALLY get curious about the Navy's plan, do this search: U.S. Navy COOP initiative

If you do this, don't blame me for getting either bored or lost in all the Navy acronyms.
 

ilanray

Member
Local time
Today, 09:31
Joined
Jan 3, 2023
Messages
116
We have a shadow copy twice a day.
But what is it have to do with the company's policy? I would like to create a copy for some tabled. I know all the other solution of IT backup. I just wanted to know if someone has an idea for me about duplicate some tables :)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:31
Joined
Feb 19, 2002
Messages
43,275
We gave you ideas. You don't seem to like them. Your idea of duplicating all updates is not workable and is too complicated. None of the experts who responded would use your requested technique. Using the log technique provides you a reference to all changes. There are several variations on logging. Take a look at those.
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:31
Joined
Sep 21, 2011
Messages
14,299
there are about 40 concurrent users and the ms-access is split database (FE & BE)
The goal of the second database is just for backup incase something will happend. and as I saidI don't want to use daily backup since if the database currepted and I will not notince on time it will overide the correct database

As for the other questions, that's what I was asking about. How to create DOCMD.RUNSQL"insert...." to two DB? or is there another way to backup a table on every transaction to another database
I would be backing up with a date and timestamp on every file?
I used to do that regularly for both FE and BE
 

ebs17

Well-known member
Local time
Today, 08:31
Joined
Feb 7, 2020
Messages
1,946
I just wanted to know if someone has an idea for me about duplicate some tables
append query
make table query
TransferDatabase
copy the hole backend

One thing is very important: Such actions should only be carried out if there are no writing actions by you or third parties to these tables.
So you'd better send your 40 users to take a break before you start.

See also
 

Cronk

Registered User.
Local time
Today, 16:31
Joined
Jul 4, 2013
Messages
2,772
You can insert records into a table in another database, if you want to go against the advice proffered by others, by using

currentdb.execute "insert into tblExternal (Field1, Field2) in 'C:\path\yourOtherDatabase.accdb' select Field1, Field2 from tblSourceTable"
 

Users who are viewing this thread

Top Bottom