Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
80bae398
Commit
80bae398
authored
Oct 31, 2011
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup vzdump backup/cron code
parent
2a911669
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
47 deletions
+52
-47
Backup.pm
PVE/API2/Backup.pm
+10
-27
VZDump.pm
PVE/API2/VZDump.pm
+4
-14
VZDump.pm
PVE/VZDump.pm
+38
-0
Backup.js
www/manager/dc/Backup.js
+0
-6
No files found.
PVE/API2/Backup.pm
View file @
80bae398
...
...
@@ -170,19 +170,12 @@ sub write_vzdump_cron_config {
}
else
{
die
"
unable to parse job start time
\n
";
}
$job
->
{
quiet
}
=
1
;
# we do not want messages from cron
my
$param
=
"";
foreach
my
$p
(
keys
%
$job
)
{
next
if
$p
eq
'
id
'
||
$p
eq
'
vmid
'
||
$p
eq
'
starttime
'
||
$p
eq
'
dow
';
my
$v
=
$job
->
{
$p
};
$param
.=
"
--
$p
"
.
PVE::Tools::
shellquote
(
$v
)
if
defined
(
$v
)
&&
$v
ne
'';
}
if
(
$job
->
{
vmid
})
{
$param
.=
"
"
.
join
('
',
PVE::Tools::
split_list
(
$job
->
{
vmid
}));
}
my
$cmd
=
PVE::VZDump::
command_line
(
$job
);
$out
.=
sprintf
"
$minute
$hour
* * %-11s root
vzdump
$param
\n
",
$dow
;
$out
.=
sprintf
"
$minute
$hour
* * %-11s root
$cmd
\n
",
$dow
;
}
my
$ejobs
=
$cfg
->
{
ejobs
}
||
[]
;
...
...
@@ -259,12 +252,7 @@ __PACKAGE__->register_method({
$param
->
{
dow
}
=
'
mon,tue,wed,thu,fri,sat,sun
'
if
!
defined
(
$param
->
{
dow
});
$param
->
{
all
}
=
1
if
defined
(
$param
->
{
exclude
});
raise_param_exc
({
all
=>
"
option conflicts with option 'vmid'
"})
if
$param
->
{
all
}
&&
$param
->
{
vmid
};
raise_param_exc
({
vmid
=>
"
property is missing
"})
if
!
$param
->
{
all
}
&&
!
$param
->
{
vmid
};
PVE::VZDump::
verify_vzdump_parameters
(
$param
,
1
);
push
@
{
$data
->
{
jobs
}},
$param
;
...
...
@@ -400,15 +388,14 @@ __PACKAGE__->register_method({
die
"
no options specified
\n
"
if
!
scalar
(
keys
%
$param
);
raise_param_exc
({
all
=>
"
option conflicts with option 'vmid'
"})
if
$param
->
{
all
}
&&
$param
->
{
vmid
};
PVE::VZDump::
verify_vzdump_parameters
(
$param
);
my
$delete
=
extract_param
(
$param
,
'
delete
'
);
my
@delete
=
PVE::Tools::
split_list
(
extract_param
(
$param
,
'
delete
')
);
foreach
my
$job
(
@$jobs
)
{
if
(
$job
->
{
id
}
eq
$param
->
{
id
})
{
foreach
my
$k
(
PVE::Tools::
split_list
(
$delete
)
)
{
foreach
my
$k
(
@delete
)
{
if
(
!
PVE::VZDump::
option_exists
(
$k
))
{
raise_param_exc
({
delete
=>
"
unknown option '
$k
'
"
});
}
...
...
@@ -422,18 +409,14 @@ __PACKAGE__->register_method({
$job
->
{
all
}
=
1
if
defined
(
$job
->
{
exclude
});
if
(
$param
->
{
vmid
}
)
{
if
(
defined
(
$param
->
{
vmid
})
)
{
delete
$job
->
{
all
};
delete
$job
->
{
exclude
};
}
elsif
(
$param
->
{
all
})
{
delete
$job
->
{
vmid
};
}
raise_param_exc
({
all
=>
"
option conflicts with option 'vmid'
"})
if
$job
->
{
all
}
&&
$job
->
{
vmid
};
raise_param_exc
({
vmid
=>
"
property is missing
"})
if
!
$job
->
{
all
}
&&
!
$job
->
{
vmid
};
PVE::VZDump::
verify_vzdump_parameters
(
$job
,
1
);
cfs_write_file
('
vzdump.cron
',
$data
);
...
...
PVE/API2/VZDump.pm
View file @
80bae398
...
...
@@ -2,7 +2,7 @@ package PVE::API2::VZDump;
use
strict
;
use
warnings
;
use
PVE::
Exception
qw(raise_param_exc)
;
;
use
PVE::
Exception
qw(raise_param_exc)
;
use
PVE::
Tools
qw(extract_param)
;
use
PVE::
Cluster
qw(cfs_register_file cfs_read_file)
;
use
PVE::
INotify
;
...
...
@@ -54,26 +54,16 @@ __PACKAGE__->register_method ({
# by default we set --rsyncable for gzip
local
$ENV
{
GZIP
}
=
"
--rsyncable
"
if
!
$ENV
{
GZIP
};
$param
->
{
all
}
=
1
if
defined
(
$param
->
{
exclude
});
raise_param_exc
({
all
=>
"
option conflicts with option 'vmid'
"})
if
$param
->
{
all
}
&&
$param
->
{
vmid
};
raise_param_exc
({
vmid
=>
"
property is missing
"})
if
!
$param
->
{
all
}
&&
!
$param
->
{
vmid
};
PVE::VZDump::
verify_vzdump_parameters
(
$param
,
1
);
# silent exit if we run on wrong node
exit
(
0
)
if
$param
->
{
node
}
&&
$param
->
{
node
}
ne
$nodename
;
my
$cmdline
=
PVE::VZDump::
command_line
(
$param
);
# convert string lists to arrays
my
@vmids
=
PVE::Tools::
split_list
(
extract_param
(
$param
,
'
vmid
'));
my
$cmdline
=
'
vzdump
';
$cmdline
.=
'
'
.
join
('
',
@vmids
)
if
scalar
(
@vmids
);
foreach
my
$p
(
keys
%
$param
)
{
$cmdline
.=
"
--
$p
$param
->{
$p
}
";
}
$param
->
{
vmids
}
=
PVE::VZDump::
check_vmids
(
@vmids
)
if
!
$param
->
{
all
};
my
@exclude
=
PVE::Tools::
split_list
(
extract_param
(
$param
,
'
exclude
'));
$param
->
{
exclude
}
=
PVE::VZDump::
check_vmids
(
@exclude
);
...
...
PVE/VZDump.pm
View file @
80bae398
...
...
@@ -3,6 +3,7 @@ package PVE::VZDump;
use
strict
;
use
warnings
;
use
Fcntl
'
:flock
';
use
PVE::
Exception
qw(raise_param_exc)
;
use
PVE::
SafeSyslog
;
use
IO::
File
;
use
IO::
Select
;
...
...
@@ -1140,4 +1141,41 @@ sub json_config_properties {
return
$prop
;
}
sub
verify_vzdump_parameters
{
my
(
$param
,
$check_missing
)
=
@_
;
raise_param_exc
({
all
=>
"
option conflicts with option 'vmid'
"})
if
$param
->
{
all
}
&&
$param
->
{
vmid
};
raise_param_exc
({
exclude
=>
"
option conflicts with option 'vmid'
"})
if
$param
->
{
exclude
}
&&
$param
->
{
vmid
};
$param
->
{
all
}
=
1
if
defined
(
$param
->
{
exclude
});
return
if
!
$check_missing
;
raise_param_exc
({
vmid
=>
"
property is missing
"})
if
!
$param
->
{
all
}
&&
!
$param
->
{
vmid
};
}
sub
command_line
{
my
(
$param
)
=
@_
;
my
$cmd
=
"
vzdump
";
if
(
$param
->
{
vmid
})
{
$cmd
.=
"
"
.
join
('
',
PVE::Tools::
split_list
(
$param
->
{
vmid
}));
}
foreach
my
$p
(
keys
%
$param
)
{
next
if
$p
eq
'
id
'
||
$p
eq
'
vmid
'
||
$p
eq
'
starttime
'
||
$p
eq
'
dow
';
my
$v
=
$param
->
{
$p
};
my
$pd
=
$confdesc
->
{
$p
}
||
die
"
no such vzdump option '
$p
'
\n
";
$cmd
.=
"
--
$p
"
.
PVE::Tools::
shellquote
(
$v
)
if
defined
(
$v
)
&&
$v
ne
'';
}
return
$cmd
;
}
1
;
www/manager/dc/Backup.js
View file @
80bae398
...
...
@@ -202,13 +202,7 @@ Ext.define('PVE.dc.BackupEdit', {
values
.
all
=
1
;
values
.
exclude
=
values
.
vmid
;
delete
values
.
vmid
;
}
else
{
if
(
!
me
.
create
)
{
PVE
.
Utils
.
assemble_field_data
(
values
,
{
'
delete
'
:
'
all
'
});
PVE
.
Utils
.
assemble_field_data
(
values
,
{
'
delete
'
:
'
exclude
'
});
}
}
return
values
;
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment