How to implement backups to run before Zincati updates?

Hi,

I’m trying to CoreOS for the first time and I’m trying to set up automatic backups that run before any system update.

I’ve previously used OpenSuse MicroOS, and the way I implemented this was with a simple systemd service like this:

[Unit]
Description=Backup Data
Before=transactional-update.service

[Service]
ExecStart=/usr/local/bin/do_backup
Type=oneshot

[Install]
RequiredBy=transactional-update.service

Whenever the transactional-update service runs (which is like rpm-ostree upgrade), my backup script runs first.

But looking through Zincati, it seems things are a bit more complex. Is there a way to hook my backup script so it runs before Zincati performs any upgrades? Or at least before it does the final reboot?

I could try scheduling them to run at different times, but I want updates to be cancelled if the backup fails.

…or is there a better approach for automating backups?

Thanks in advance!

See the following example of how to write a systemd unit to run before zincati.service.

It depends on what you want to backup, but in general for Fedora CoreOS you likely don’t need to backup the system, so probably important configs in /etc and data in /var.

1 Like