Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update table just before/after backup [CORE3230] #3603

Closed
firebird-automations opened this issue Nov 12, 2010 · 14 comments
Closed

Update table just before/after backup [CORE3230] #3603

firebird-automations opened this issue Nov 12, 2010 · 14 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Paweł Przybyła (pprzybyla)

Hi.
Is it possible to execute procedure just before (or just after) backup database ?
I need somethink like trigger (before or after) on backup.

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Please explain what you need the "trigger" for.

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

I need create mechanizm which execute procedure to set some values on one of tables (value - after_backup = 'Y').
Because I need to now after connect to this database that its just after backup . I need do that automaticly, because the backups do many administrators in different ways - I've got 350 databases so I don't know if there are after_backup.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

I'm wondering what it could be useful for. What if a backup has been lost after setting values to 'Y'?

I suppose an ON DISCONNECT trigger with a select against MON$ATTACHMENTS to check whether it was a backup connection (see CORE3135) would achieve that goal.

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

I just need to know that the database was restore from backup when I connect to it first time after restore. If I update field in one of table (after_backup = Y) that be enough. But I don't know how to set it when I backuping Database or when I restoring ...

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

BTW MON$ATTACHMENTS shows not enought information because like I wrote the backup is creating for many ways for examlple : GBak, Ibexpert, my application - so I don't if the backup was make.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

I think you should better make your own backup program (which may use the FB tools / API) to put your needed logic.

There are different kind of backups... GBAK from client or server, nbackup and even directly file copy with the database closed. I don't think a trigger for backup could be generally useful.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

In your case, I'd check for CURRENT_CONNECTION inside the ON CONNECT trigger and if it's < 5 (for example) then it means the database has just been restored.

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

Thanks for help. Thats all I need.

CREATE OR ALTER trigger after_backup
active on connect position 0
AS
BEGIN

if (CURRENT_CONNECTION = 3) then
begin
update syncT
set AFTER_BACKUP = 'Y';
end

END

Do you know why my first connection after restore has ID = 3 ? Where's first and second connection ? First I gues is for restore and second... ???
Anyway thanks again.

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

You realize that it is very possible for a any connection to get ID = 3, right?

As such you should check that AFTER_BACKUP <> 'Y' prior to executing "update syncT".

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

I restore backup for 3 ways (no more possible in my case): IBExpert, Consol+gback, myApplication. After that I connect to database and check current_connection that always was 3. I don't care what connection gets 3. For me was enought that I know that connection (3) was first connection to database after restore. My column after_backup has wrong name it shoud be 'after_restor' :)

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

The backup/restore code does two connections to the database during the restore process, hence IDs 1 and 2.

@firebird-automations
Copy link
Collaborator Author

Commented by: Paweł Przybyła (pprzybyla)

Thats all I need . Thank You.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant