0

I have an anacron job that creates zfs snapshots using zfs-auto-snapshot package.

I now want to create a job that sends the latest snapshot via zfs send to a backup server.

As I understood, anacron means it will run the jobs anachronistic at least once a hour, day, week, month etc. So if I just create a second job hourly containing zfs send command, it will just run it when ever it can once a hour.

That would mean, that the backup job could run before or parallel to the snapshot job, is that correct?

If yes, how do I make sure that snapshot is always finished before backup runs?

  • 2
    Why don't you combine the two tasks in one job rather than trying to synchronise two separate jobs? – Kusalananda Jun 20 '19 at 11:15
  • @Kusalananda because I was not sure if I should do this – user6329530 Jun 20 '19 at 11:24
  • 1
    @user6329530 Why wouldn't you be able to? You can just put both into the same script and use && so that the second one runs when the first is completed. – Nasir Riley Jun 20 '19 at 11:34
  • @NasirRiley thanks – user6329530 Jun 20 '19 at 11:47
  • @NasirRiley unfortunately that doesn't work because I need to state the exact name of the snapshot created to transfer it, I can't transfer all snapshots at once... – user6329530 Jun 20 '19 at 16:36
  • @user6329530 Then set the name of the snapshot to a shell variable and use that to transfer it. – Nasir Riley Jun 20 '19 at 16:40
  • @NasirRiley my anacron job does this: exec zfs-auto-snapshot --quiet --syslog --label=hourly --keep=240 // where // means "snapshot all pools" I have two pools, this creates hourly snapshots for each pool. I need to send these hourly snaps to the backup system as soon as they are created. – user6329530 Jun 20 '19 at 16:45
  • What is stopping you from doing what I suggested? Each snapshot has a name after its created, yes? Assign the name to a shell variable in the second part of your script and transfer it. – Nasir Riley Jun 20 '19 at 17:46
  • @NasirRiley yeah but the name is automatically created... – user6329530 Jun 20 '19 at 17:55
  • Then get the name after it's created, assign it to a shell variable, and transfer it. – Nasir Riley Jun 20 '19 at 19:49

0 Answers0