Skip to content

Commit 39a3ce0

Browse files
committed
Add quiesce option to createBackup and CreateBackupSchedule
1 parent f703751 commit 39a3ce0

File tree

22 files changed

+179
-25
lines changed

22 files changed

+179
-25
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ public class ApiConstants {
464464
public static final String REGISTERED = "registered";
465465
public static final String QUALIFIERS = "qualifiers";
466466
public static final String QUERY_FILTER = "queryfilter";
467+
public static final String QUIESCE_VM = "quiescevm";
467468
public static final String SCHEDULE = "schedule";
468469
public static final String SCHEDULE_ID = "scheduleid";
469470
public static final String SCOPE = "scope";

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupCmd.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ public class CreateBackupCmd extends BaseAsyncCreateCmd {
8181
since = "4.21.0")
8282
private Long scheduleId;
8383

84+
@Parameter(name = ApiConstants.QUIESCE_VM,
85+
type = CommandType.BOOLEAN,
86+
required = false,
87+
description = "Quiesce the instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
88+
"The filesystem is frozen before the backup starts and thawed immediately after. " +
89+
"Requires the instance to have the QEMU Guest Agent installed and running.",
90+
since = "4.21.0")
91+
private Boolean quiesceVM;
92+
8493
/////////////////////////////////////////////////////
8594
/////////////////// Accessors ///////////////////////
8695
/////////////////////////////////////////////////////
@@ -105,6 +114,10 @@ public Long getScheduleId() {
105114
}
106115
}
107116

117+
public Boolean getQuiesceVM() {
118+
return quiesceVM;
119+
}
120+
108121
/////////////////////////////////////////////////////
109122
/////////////// API Implementation///////////////////
110123
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupScheduleCmd.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ public class CreateBackupScheduleCmd extends BaseCmd {
8181
since = "4.21.0")
8282
private Integer maxBackups;
8383

84+
@Parameter(name = ApiConstants.QUIESCE_VM,
85+
type = CommandType.BOOLEAN,
86+
required = false,
87+
description = "Quiesce the instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
88+
"The filesystem is frozen before the backup starts and thawed immediately after. " +
89+
"Requires the instance to have the QEMU Guest Agent installed and running.",
90+
since = "4.21.0")
91+
private Boolean quiesceVM;
92+
8493
/////////////////////////////////////////////////////
8594
/////////////////// Accessors ///////////////////////
8695
/////////////////////////////////////////////////////
@@ -105,6 +114,10 @@ public Integer getMaxBackups() {
105114
return maxBackups;
106115
}
107116

117+
public Boolean getQuiesceVM() {
118+
return quiesceVM;
119+
}
120+
108121
/////////////////////////////////////////////////////
109122
/////////////// API Implementation///////////////////
110123
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/BackupScheduleResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public class BackupScheduleResponse extends BaseResponse {
5353
@Param(description = "maximum number of backups retained")
5454
private Integer maxBakups;
5555

56+
@SerializedName(ApiConstants.QUIESCE_VM)
57+
@Param(description = "quiesce the instance before checkpointing the disks for backup")
58+
private Boolean quiesceVM;
59+
5660
public String getVmName() {
5761
return vmName;
5862
}
@@ -96,4 +100,8 @@ public void setTimezone(String timezone) {
96100
public void setMaxBakups(Integer maxBakups) {
97101
this.maxBakups = maxBakups;
98102
}
103+
104+
public void setQuiesceVM(Boolean quiesceVM) {
105+
this.quiesceVM = quiesceVM;
106+
}
99107
}

api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ public interface BackupProvider {
7070
/**
7171
* Starts and creates an adhoc backup process
7272
* for a previously registered VM backup
73-
* @param vm the machine to make a backup of
73+
*
74+
* @param vm the machine to make a backup of
75+
* @param quiesceVM instance will be quiesced for checkpointing for backup. Applicable only to NAS plugin.
7476
* @return the result and {code}Backup{code} {code}Object{code}
7577
*/
76-
Pair<Boolean, Backup> takeBackup(VirtualMachine vm);
78+
Pair<Boolean, Backup> takeBackup(VirtualMachine vm, Boolean quiesceVM);
7779

7880
/**
7981
* Delete an existing backup

api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ public interface BackupSchedule extends InternalIdentity {
3131
Date getScheduledTimestamp();
3232
Long getAsyncJobId();
3333
Integer getMaxBackups();
34+
Boolean getQuiesceVM();
3435
}

core/src/main/java/org/apache/cloudstack/backup/TakeBackupCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class TakeBackupCommand extends Command {
3030
private String backupRepoType;
3131
private String backupRepoAddress;
3232
private List<String> volumePaths;
33+
private Boolean quiesce;
3334
@LogLevel(LogLevel.Log4jLevel.Off)
3435
private String mountOptions;
3536

@@ -87,6 +88,14 @@ public void setVolumePaths(List<String> volumePaths) {
8788
this.volumePaths = volumePaths;
8889
}
8990

91+
public Boolean getQuiesce() {
92+
return quiesce;
93+
}
94+
95+
public void setQuiesce(Boolean quiesce) {
96+
this.quiesce = quiesce;
97+
}
98+
9099
@Override
91100
public boolean executeInSequence() {
92101
return true;

engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ public class BackupScheduleVO implements BackupSchedule {
6161
@Column(name = "max_backups")
6262
Integer maxBackups = 0;
6363

64+
@Column(name = "quiescevm")
65+
Boolean quiesceVM = false;
66+
6467
public BackupScheduleVO() {
6568
}
6669

67-
public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, Integer maxBackups) {
70+
public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, Integer maxBackups, Boolean quiesceVM) {
6871
this.vmId = vmId;
6972
this.scheduleType = (short) scheduleType.ordinal();
7073
this.schedule = schedule;
7174
this.timezone = timezone;
7275
this.scheduledTimestamp = scheduledTimestamp;
7376
this.maxBackups = maxBackups;
77+
this.quiesceVM = quiesceVM;
7478
}
7579

7680
@Override
@@ -140,4 +144,12 @@ public Integer getMaxBackups() {
140144
public void setMaxBackups(Integer maxBackups) {
141145
this.maxBackups = maxBackups;
142146
}
147+
148+
public void setQuiesceVM(Boolean quiesceVM) {
149+
this.quiesceVM = quiesceVM;
150+
}
151+
152+
public Boolean getQuiesceVM() {
153+
return quiesceVM;
154+
}
143155
}

engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public BackupScheduleResponse newBackupScheduleResponse(BackupSchedule schedule)
9898
response.setSchedule(schedule.getSchedule());
9999
response.setTimezone(schedule.getTimezone());
100100
response.setMaxBakups(schedule.getMaxBackups());
101+
if (schedule.getQuiesceVM() != null) {
102+
response.setQuiesceVM(schedule.getQuiesceVM());
103+
}
101104
response.setObjectName("backupschedule");
102105
return response;
103106
}

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ END;
202202

203203
-- Add column max_backup to backup_schedule table
204204
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule', 'max_backups', 'int(8) default NULL COMMENT "maximum number of backups to maintain"');
205+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule', 'quiescevm', 'tinyint(1) default NULL COMMENT "Quiesce VM before taking backup"');
205206

206207
-- Add columns name, description and backup_interval_type to backup table
207208
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backups', 'name', 'VARCHAR(255) NULL COMMENT "name of the backup"');

0 commit comments

Comments
 (0)