XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Creating schedules to run on specific days.

    Scheduled Pinned Locked Moved Xen Orchestra
    12 Posts 3 Posters 1.4k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • olivierlambertO Online
      olivierlambert Vates 🪐 Co-Founder CEO
      last edited by

      You maybe missed the small toggle in the UI "Switch to week days"

      1 Reply Last reply Reply Quote 0
      • pianonP Offline
        pianon
        last edited by pianon

        Thanks for your reply.

        I tried to play around with it, but each time i switch to week days, the schedule loses its patterns for the month days.

        My method was:
        In month day view select day 1 to 7, switch to week day selection and select only sunday.

        But if i switch to week days like described, the pattern becomes like this:

        Sunday, September 13, 2020, 6:00 PM
        Sunday, September 20, 2020, 6:00 PM
        Sunday, September 27, 2020, 6:00 PM

        and so on...

        1 Reply Last reply Reply Quote 0
        • olivierlambertO Online
          olivierlambert Vates 🪐 Co-Founder CEO
          last edited by

          Ping @Rajaa-BARHTAOUI or badrAZ on this

          1 Reply Last reply Reply Quote 0
          • pianonP Offline
            pianon
            last edited by pianon

            Thank you.

            I will try the same procedure on another XOA;

            perhaps this behaviour is due to some fault with the one i'm trying to create the schedule on.

            1 Reply Last reply Reply Quote 0
            • pianonP Offline
              pianon
              last edited by pianon

              Works in the GUI the same on each of my 5 XOA servers.

              so i edited the schedule via xo-cli

              [15:10:04][root@mgmt:~]$ xo-cli schedule.set cron="0 18 1-7 * 0" id=4d011d64-cd11-45cd-adf1-995ac44d1411
              

              as i expected the pattern becomes like this

              Sunday, September 13, 2020, 6:00 PM
              Sunday, September 20, 2020, 6:00 PM
              Sunday, September 27, 2020, 6:00 PM
              Thursday, October 1, 2020, 6:00 PM
              Friday, October 2, 2020, 6:00 PM
              Saturday, October 3, 2020, 6:00 PM
              Sunday, October 4, 2020, 6:00 PM
              
              1 Reply Last reply Reply Quote 0
              • pianonP Offline
                pianon
                last edited by pianon

                i worked around my problem by creating a delta backup job with a full backup interval, such that the full backup would only run on a sunday every four weeks.

                Still, for backup plans which do not contain incremental backups, this obviously wouldn't work.

                1 Reply Last reply Reply Quote 0
                • badrAZB Offline
                  badrAZ
                  last edited by

                  Hi pianon

                  Unfortunately, there is an exception in cron when the day of week and the day of month are set together.

                  if both "day of month" and "day of week" are restricted (not "*"), then one or both must match the current day
                  https://en.wikipedia.org/wiki/Cron

                  So, we have no way to tell cron to execute a backup job each Sunday of the first week of the month.

                  1 Reply Last reply Reply Quote 0
                  • pianonP Offline
                    pianon
                    last edited by pianon

                    Hello and thanks for replying badrAZ

                    Ye i was curious how you implemented the cron schedules in XOA.

                    Of course, cron doesn't allow for an and-logic in itself so i wondered if i could prepend some condition to the backup job.

                    On systems which allow creating manual entries in cron-files i usually do as i showed the first posting, if i wish for more specificity. (and i suspect you don't edit crontabs in XOA by yourself)

                    Again, like this (or whatever your condition might be)

                    0 0 1-7 * *  [ $(date +\%u) -eq 7 ] && backup
                    

                    It would mean, the schedule runs every day of month from 1 to 7, but the backup would only run if the previous statement exits with zero which is when day of week equals to 7.

                    is there a way in XOA to configure a job or so to mimic this behaviour?

                    1 Reply Last reply Reply Quote 0
                    • badrAZB Offline
                      badrAZ
                      last edited by

                      Currently, there is no way to add a predicate to the job execution.

                      But, it's possible to do a work-around that responds to your need using xo-cli and your cron.

                      You can let your cron run manually the backup job using xo-cli backupNg.runJob id:jobId schedule:scheduleId.

                      1 Reply Last reply Reply Quote 1
                      • pianonP Offline
                        pianon
                        last edited by pianon

                        Yes that makes sense, thank you very much.

                        Makes me think managing backups via xo-cli like you proposed would work a lot smoother for multiple XOA instances versus doing it in the gui.

                        Is it even mandatory for a Job to also have a schedule attached, if i run it using /etc/crontab?
                        i guess i'll figure this one out for myself.

                        1 Reply Last reply Reply Quote 0
                        • badrAZB Offline
                          badrAZ
                          last edited by

                          Yes, backup jobs require attached schedules to be executed properly.

                          1 Reply Last reply Reply Quote 0
                          • M McHenry referenced this topic on
                          • First post
                            Last post