Transaction begin|end|rollback
LocalTransaction begin|end|rollback
RemoteTransaction begin|end|rollback
PyroBatchFTP supports basic transaction control. A transaction is a block of commands which form a logical operation and which should either be executed together or not at all. PyroBatchFTP is able to undo the commands locally, remotely or on both computers if there one of the commands fails.
The block of commands will be framed by a Transaction begin and a Transaction end command. If the end command is not executed because of an error (either if the script terminates or if the Transaction end command is skipped due to an OnError command) all file operations since the Transaction begin command will be undone. The undo can also be forced by executing a Transaction rollback.
The Transaction command will start a transaction synchronously on the local and remote machine while LocalTransaction and RemoteLocalTransaction will apply only to the respective computer.
Note: Only the PyroServer/Pro server will support remote transactions, i.e. for PyroBatchFTP connections and PyroBatch conntections to servers other than PyroServer/Pro only the LocalTransaction commands will work.
Transaction Subcommands:
begin | |
Starts a transaction sequence. Nested transactions are not allowed and
will result in an error.
| |
end | |
Completes a transaction sequence. Ending without beginning is an error.
| |
rollback | |
Reverses all file commands since the last begin command. Rollback implies end. Rollback outside a begin/end block is allowed but is ignored. |
Example 1: Creates a remote directory and moves three file there.
If an error occurs, the script will abort and automatically perform a
LocalTransaction rollback which will restore the deleted (moved)
files on the local computer. PyroServer/Pro will also automatically
perform a rollback and delete the received files and the directory when
a connection is terminated without a Transaction end command.
Transaction begin
RemoteMkDir "newsales"
RemoteChDir "newsales"
PutMove "Sales.dat"
PutMove "Expenses.dat"
PutMove "Reports.dat"
Transaction end
Disconnect
Example 2: Same as above, but a multi site script. If an error occurs on site 1, the script will skip to the :NextSite label (ignoring the Transaction end) and will do a local rollback as in Example 1. The server will do the same, either because it will receive the rollback command or, if the connection was lost, it will perform rollback automatically because it did not receive the LocalTransaction end command.
However, if site 1 is processed without error, the script will
execute the Transaction end command. After that, the rollback
command will do nothing (see above description for rollback).
Connect ...
OnError SkipTo Nextsite
Transaction begin
RemoteMkDir "newsales"
RemoteChDir "newsales"
PutMove "Sales1.dat"
PutMove "Expenses1.dat"
PutMove "Reports1.dat"
Transaction end
:NextSite
Transaction rollback
-Disconnect
// site 2
Connect ...
Transaction begin
...
← Back to Script Commands