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

Using env variables ZNAP_NAME and ZNAP_TIME within pre and post send commands #674

Open
kevdogg opened this issue Sep 15, 2024 · 1 comment

Comments

@kevdogg
Copy link

kevdogg commented Sep 15, 2024

In regards to the documentation, the variables ZNAP_NAME and ZNAP_TIME are defined by:

--pre-snap-command=/path/bin args, --post-snap-command=/path/bin args
Run commands/scripts before and after snapshots are taken on source. e.g. for database locking/flushing (pre) and unlocking (post).

The pre and post snapshot commands can find the name and time of the snapshot in the environment variables ZNAP_NAME and ZNAP_TIME.

Am I able to send ZNAP_NAME and ZNAP_TIME to scripts running with the pre-send/post-send commands?:

pre-send-command=/path/bin args, post-send-command=/path/bin args
Run command/script before and after sending the snapshot to the destination

@jimklimov
Copy link
Contributor

Interesting idea, but currently I think "no".

Now git grep ZNAP_ only found me one hit for each:

$ git grep ZNAP_
CHANGES.old:    document ZNAP_* environement variables (#277)
bin/znapzendzetup:snapshot in the environment variables I<ZNAP_NAME> and I<ZNAP_TIME>.
doc/znapzendzetup.pod:snapshot in the environment variables I<ZNAP_NAME> and I<ZNAP_TIME>.
lib/ZnapZend.pm:    local $ENV{ZNAP_NAME} = $snapshotName;
lib/ZnapZend.pm:    local $ENV{ZNAP_TIME} = $timeStamp;
lib/ZnapZend.pm:    delete $ENV{ZNAP_NAME};
lib/ZnapZend.pm:    delete $ENV{ZNAP_TIME};
man/znapzendzetup.1:snapshot in the environment variables \fI\s-1ZNAP_NAME\s0\fR and \fI\s-1ZNAP_TIME\s0\fR.

Those assignments and deletions happen in my $createSnapshot = sub {... definition.

You can try copying them to $refreshBackupPlans and/or $sendRecvCleanup definitions (search for [Pp](re|ost).*[Ss]end regex); they already deal with $ENV{WORKER} (actually can just search for it), so add copies of those lines nearby.

If it works, I suppose a PR would be welcomed by @oetiker :)

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

No branches or pull requests

2 participants