Postfilebackup should be capable of running even if backup was not fully successful

Currently, the postfilebackup script will only run if the backup was totally successful. If the backup was ‘completed with errors’ it will not fire.

This is problematic when prefilebackup is being used to shut down a database or other application, and postfilebackup is being used to start it back up again.

Even if the backup is not fully successful, we want those applications to start back up again. Either, postfilebackup should run regardless of outcome, or it should be passed parameters with the status of the backup so the administrator can determine whether actions should fire only if the backup is successful or regardless of success.

I am in the exact situation and I have also just tested this, the postfilebackup script won’t run if the backup fails (client on Ubuntu).

@uroni is there a way to force the script to run regardless of the backup status? Or is there a better way to start our services once the backup finishes or fails?

Please see Dmitrius7 scripts in: Start services after snapshot created (not after backup finished)

This may solve your problem. Works fine for me.

1 Like

Thanks @DrRSatzteil. I’ll give that a try.

Do you happen to know if the postfileindex still starts the services if UrBackup doesn’t have any errors? I don’t want it starting the services if UrBackup is able to continue with the file backups because when the service is running it is constantly updating the files that I want to backup.

Interestingly postfileindex that is mentioned in that thread is not in the docs. But thanks for the pointer

Hi mahomed,

The postfileindex is only called after successfully indexing the data. Dmitrius7 scripts check if one of the prefilebackup steps fail and then actively calls the postfileindex (so it is not called by urbackup itself). For your use case you may need to stick to postfilebackup however (and maybe adjust the scripts a little) if you do not use a snapshot mechanism. If you use a snapshot mechanism it is usually better to restart your services in postfileindex as this will be called before the actual data is copied.

Actually I just checked the scripts again: They also call postfilebackup if prefilebackup was unsuccessful, so just put the commands in the right places and you should be good to go.

I added a call to postfilebackup_failed to 2.4.x just now. That said:

  • If using snapshots using postfileindex is obviously better because of less service downtime
  • postfilebackup_failed might not get called if client and server loose connectivity
  • The server retries file backups usually so just handle case that the service is already stopped in prefilebackup?
  • You can also abuse the snapshot script to start/stop services. Create a snapshot script that doesn’t create a snapshot but stops the service and a snapshot removal script that starts the service. If you backup multiple volumes with different services this can even have the advantage that the service gets started again as soon as the backup is finished with a volume.
1 Like

I can’t find documentation on postfileindex or postfilebackup_failed. Can someone point me towards where they are documented?

Thanks @uroni. This will help. Do you know when I’d be able to use the updated version? I’m using the backup appliance.

On a related note, from my testing, postfileindex is called regardless of whether the fileindex had an error or not. This is fine. My question is, how do I check that UrBackup failed to index? urbackupclientctl status does not tell me whether the last backup failed or not. Reading logs is not a reliable way tbh.

I accept that this is a moot point as my problem will be fixed by waiting for the next 2.4.x release. But it would be good to know. Thanks.

From what I understand, these are new features not yet documented.