Skip to content

Commit 1981469

Browse files
committed
feat(backup): add chain-metadata keys + nas.backup.full.every config
NASBackupChainKeys defines the keys this provider stores under the existing backup_details kv table (parent_backup_id, bitmap_name, chain_id, chain_position, type). This keeps the backups table provider-agnostic per the RFC review. nas.backup.full.every is a zone-scoped ConfigKey that controls how often a full backup is taken; the remaining backups in the cycle are incremental. Counts backups (not days), so it works for hourly, daily, and ad-hoc schedules. Default 10. Set to 1 to disable incrementals (every backup is full). Refs: #12899
1 parent f2a9202 commit 1981469

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.backup;
18+
19+
/**
20+
* Keys used by the NAS backup provider when storing incremental-chain metadata
21+
* in the existing {@code backup_details} key/value table. Stored here (not on
22+
* the {@code backups} table) so other providers do not need a schema change to
23+
* support their own incremental implementations.
24+
*/
25+
public final class NASBackupChainKeys {
26+
27+
/** UUID of the parent backup (full or previous incremental). Empty for full backups. */
28+
public static final String PARENT_BACKUP_ID = "nas.parent_backup_id";
29+
30+
/** QEMU dirty-bitmap name created by this backup, used as the {@code <incremental>} reference for the next one. */
31+
public static final String BITMAP_NAME = "nas.bitmap_name";
32+
33+
/** Identifier shared by every backup in the same chain (the full anchors a chain; its incrementals inherit the id). */
34+
public static final String CHAIN_ID = "nas.chain_id";
35+
36+
/** Position within the chain: 0 for the full, 1 for the first incremental, and so on. */
37+
public static final String CHAIN_POSITION = "nas.chain_position";
38+
39+
/** Backup type marker: {@value #TYPE_FULL} or {@value #TYPE_INCREMENTAL}. Mirrors {@code backups.type} for fast lookup without a join. */
40+
public static final String TYPE = "nas.type";
41+
42+
public static final String TYPE_FULL = "full";
43+
public static final String TYPE_INCREMENTAL = "incremental";
44+
45+
private NASBackupChainKeys() {
46+
}
47+
}

plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
8585
true,
8686
BackupFrameworkEnabled.key());
8787

88+
ConfigKey<Integer> NASBackupFullEvery = new ConfigKey<>("Advanced", Integer.class,
89+
"nas.backup.full.every",
90+
"10",
91+
"Take a full NAS backup every Nth backup; remaining backups in between are incremental. " +
92+
"Counts backups, not days, so it works for hourly, daily, and ad-hoc schedules. " +
93+
"Set to 1 to disable incrementals (every backup is full).",
94+
true,
95+
ConfigKey.Scope.Zone,
96+
BackupFrameworkEnabled.key());
97+
8898
@Inject
8999
private BackupDao backupDao;
90100

@@ -629,7 +639,8 @@ public Boolean crossZoneInstanceCreationEnabled(BackupOffering backupOffering) {
629639
@Override
630640
public ConfigKey<?>[] getConfigKeys() {
631641
return new ConfigKey[]{
632-
NASBackupRestoreMountTimeout
642+
NASBackupRestoreMountTimeout,
643+
NASBackupFullEvery
633644
};
634645
}
635646

0 commit comments

Comments
 (0)