Commit Graph

42 Commits

Author SHA1 Message Date
Fiona Ebner
2b233ecc08 api: vzdump: soften parameter permission checks
Allows sufficiently privileged users to pass-in retention and
performance parameters for manual backup, but keeps tmpdir, dumpdir
and script root-only. Such users could already edit the job
accordingly, so essentially not granting anything new.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-21 14:13:05 +01:00
Fiona Ebner
082e029758 api: backup: auto-inject job id where expected by the API
for backwards compatibility. Otherwise, e.g. listing backup jobs with
pvesh get /cluster/backup is broken. And suddenly not having the
property anymore would be a breaking API change.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-15 13:29:34 +01:00
Thomas Lamprecht
6f2e57c050 jobs: move base registry to pve-common & split vzdump base out to guest-common
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-12 16:59:38 +01:00
Dominik Csapak
2cf7706e3d Jobs: fix scheduling after updating job from a different node
since the jobs are configured clusterwide in pmxcfs, a user can use any
node to update the config of them. for some configs (schedule/enabled)
we need to update the last runtime in the state file, but this
is sadly only node-local.

to also update the state file on the other nodes, we introduce
a new 'detect_changed_runtime_props' function that checks and saves relevant
properties from the config to the statefile each round of the scheduler if they
changed.

this way, we can detect changes in those and update the last runtime too.

the only situation where we don't detect a config change is when the
user changes back to the previous configuration in between iterations.
This can be ignored though, since it would not be scheduled then
anyway.

in 'synchronize_job_states_with_config' we switch from reading the
jobstate unconditionally to check the existance of the statefile
(which is the only condition that can return undef anyway)
so that we don't read the file multiple times each round.

Fixes: 0c8d7468 ("fix #4053: don't run vzdump jobs when they change from
disabled->enabled")

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2022-08-05 13:08:08 +02:00
Dominik Csapak
0c8d746815 fix #4053: don't run vzdump jobs when they change from disabled->enabled
by updating the timestamp in the job state when enabled is changing
from 0 -> 1. We do it this way too in PBS for example, and is the more
sensible behaviour.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2022-06-17 17:21:56 +02:00
Dominik Csapak
c61c192e17 fix #4026: add 'repeat-missed' option for jobs
like systemd-timers 'persistent'. so that the user can configure it to not be
run after powering up when it was previously missed

this reverses the default behaviour to not run missed jobs after pvescheduler
was started, since most of the time that's not the desired behaviour

since we don't use it for updated schedules anymore, rename
'updated_job_schedule' to 'update_last_runtime'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2022-06-17 17:21:56 +02:00
Dominik Csapak
81ba0803d5 fix #3976: api/backup: make schedule/starttime truly optional on update
on create we require either starttime (+dow) or a schedule, but when
updating an existing job, this is not necessary

before we changed to schedules, the starttime was not optional either on
update, but i think there is no reason to require the user to send the
schedule/startime along every time.

the gui will send all values every time, so that was never a problem there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-04-01 17:52:10 +02:00
Wolfgang Bumiller
9ee9991032 switch to Proxmox::RS::CalendarEvent
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-03-17 14:02:16 +01:00
Dominik Csapak
c048ad30c8 vzdump: add new 'next-run' field for vzdump job listing
and calculate it by getting the next event after 'now' since
we currently have no way to get the last run time for jobs only running
on different cluster nodes

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-01-13 15:33:41 +01:00
Thomas Lamprecht
5cc0c3a008 api: backup: code reduction
had it lying around and did not felt condensed/code-golfed to me,
rather a bit more expressive (surely biased though)..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-17 15:57:55 +01:00
Thomas Lamprecht
de92b4d783 api: backup: add comment regarding normalizing DOW list
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-17 15:36:06 +01:00
Dominik Csapak
307b2608a5 api: backup: normalize 'dow' format when converting
the old web ui sends the days as seperate parameters, which will
be concatenated by a null-byte in the api, causing it to land it this
way in the jobs.cfg

to fix this, split+join the list to get a well-formed dow list

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-17 15:22:45 +01:00
Fabian Grünbichler
1c87d3447c fix use statement
else this happens:

"Use of inherited AUTOLOAD for non-method PVE::API2::Backup::uuid() is
no longer allowed at /usr/share/perl5/PVE/API2/Backup.pm line 198.
(500)"

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-11-17 15:07:12 +01:00
Dominik Csapak
ca62f164cd api: backup: correclty use uuid package
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-17 15:07:12 +01:00
Dominik Csapak
998b61fbff api: backup/jobs: add comment field to jobs
and encode them with PVE::Tools::encode_text in the config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-10 16:11:42 +01:00
Dominik Csapak
305921b1ab api/backup: handle new vzdump jobs
in addition to listing the vzdump.cron jobs, also list from the
jobs.cfg file.

updates/creations go into the new jobs.cfg only now
and on update, starttime+dow get converted to a schedule
this transformation is straight forward, since 'dow'
is already in a compatible format (e.g. 'mon,tue') and we simply
append the starttime (if any)

id on creation is optional for now (for api compat), but will
be autogenerated (uuid). on update, we simply take the id from before
(the ids of the other entries in vzdump.cron will change but they would
anyway)

as long as we have the vzdump.cron file, we must lock both
vzdump.cron and jobs.cfg, since we often update both

we also change the backupinfo api call to read the jobs.cfg too

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-10 16:11:00 +01:00
Dominik Csapak
85b9ba88f1 api/backup: refactor string for all days
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-11-10 16:11:00 +01:00
Aaron Lauterer
ac0fe8b66c api: backup: add endpoint to list included guests and volumes
This patch adds a new API endpoint that returns a list of included
guests, their volumes and whether they are included in a backup.

The output is formatted to be used with the extJS tree panel.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2020-07-09 14:12:59 +02:00
Thomas Lamprecht
e6d963ca3e backup: update job: add missing permission description
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-08 13:53:57 +02:00
Thomas Lamprecht
2617768f2c backup: factor out param permission check
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-08 13:48:21 +02:00
Oguz Bektas
d5b9f2e1cb backup: add missing user check in update_job
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2020-07-08 13:41:38 +02:00
Christian Ebner
2424074ee7 vzdump: move code needed for cfs register of vzdump.cron to guest-common
This moves the cfs register code for vzdump.cron to the
pve-guest-common package. Therefore, it relies on the corresponding
patches in pve-guest-common and pve-docs as build dependencies.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 08:23:40 +02:00
Stefan Reiter
b05c990876 Delete "exclude" when switching a backup job to pool mode
If you updated a job in "exclude" mode with some VMIDs specified to "pool" mode,
the backup job would retain the "exclude" section and thus not back up all VMs.

The GUI misrepresents this, showing that all VMs will be backed up or
straight up break and show "exclude" mode again, with the backend still
being on "pool" - to prevent this, we always delete a jobs "exclude" list
when it's switched to "pool".

Co-authored-by: Tim Marx <t.marx@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-08-16 13:09:42 +02:00
Stefan Reiter
43b2494b79 Code cleanup in Backup
Whitespace removal and consolidating VZDump's job id format into a
local variable.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-08-14 14:02:53 +02:00
Thomas Lamprecht
c92c54d54b api: backup pool: enforce VM.Backup permissions on pool also on create
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-28 20:04:04 +02:00
Thomas Lamprecht
16f5b2834e api: backup pool: enforce VM.Backup permissions on pool
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-28 19:29:46 +02:00
Tim Marx
f337626155 fix #1278 api: add pool backup option
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-28 18:05:19 +02:00
Tim Marx
60e049c231 whitespace cleanup
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-28 18:01:04 +02:00
Christian Ebner
200cef80ee backup jobs: Aquire lock before modifying vzdump.cron
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-25 11:43:31 +02:00
Fabian Grünbichler
f0bbc08419 restrict vzdump cron options
modeled after the VZDump API path, but since we are
restricted to Sys.Modify users already, we only need to
restrict these three options.
2016-10-17 10:36:06 +02:00
Thomas Lamprecht
4341db1d2f Added functionality do disable temporary a backup job
Added an option to disable a backup job while preserving its
settings. When a job is disabled a '#' is added in front of the vzdump
command in the vzdump.cron file. So the cron job still fires,
but only a comment gets executed. If we would comment out the cron job
a bit more changes to the parser would be needed.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2015-07-27 09:15:09 +02:00
Dietmar Maurer
94c47be79d fix typo 2015-06-02 08:42:32 +02:00
Tobias Doerffel
f9adc7763d Fixed typo in backup API
Signed-off-by: Tobias Doerffel <tobias.doerffel@ed-chemnitz.de>
2014-11-24 06:36:48 +01:00
Dietmar Maurer
52878b0a38 use Digest::SHA instead of Digest::SHA1 2012-03-20 12:33:38 +01:00
Dietmar Maurer
937515d61b add permissions for backup API 2012-02-06 08:17:25 +01:00
Dietmar Maurer
4baf5d13d1 use new syntax for PVE::JSONSchema::get_options 2011-11-24 12:22:24 +01:00
Dietmar Maurer
31aef76131 cleanup vzdump backup/cron code 2011-10-31 08:47:18 +01:00
Dietmar Maurer
b0905e3a84 use vzdump.cron instead of vzdump 2011-10-31 07:33:04 +01:00
Dietmar Maurer
53c6bb6cde add delete option to backup api 2011-10-28 07:59:00 +02:00
Dietmar Maurer
7625ea19ee use starttime hh:mm instead of hour and minute 2011-10-27 09:44:24 +02:00
Dietmar Maurer
063bb19ba8 correctly quote shell arguments inside vzdump cron file 2011-10-25 13:09:49 +02:00
Dietmar Maurer
ac27b58d10 finnish and cleanup vzdump API 2011-10-25 09:28:55 +02:00