|
| 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 | + /** |
| 40 | + * In-memory chain-mode sentinels used by {@code ChainDecision.mode}. The persisted |
| 41 | + * full-vs-incremental backup type lives on the {@code backup.type} column (set in |
| 42 | + * {@code takeBackup}) — single source of truth. Not duplicated into backup_details. |
| 43 | + */ |
| 44 | + public static final String TYPE_FULL = "full"; |
| 45 | + public static final String TYPE_INCREMENTAL = "incremental"; |
| 46 | + // Feature disabled: behave exactly like the pre-incremental full-only backup — no QEMU |
| 47 | + // bitmap/checkpoint is created and no chain metadata is persisted. Matches nasbackup.sh's |
| 48 | + // "legacy-full" mode token (which sets make_checkpoint=0). |
| 49 | + public static final String TYPE_LEGACY_FULL = "legacy-full"; |
| 50 | + |
| 51 | + /** |
| 52 | + * VM-scoped detail (stored in {@code vm_instance_details}) holding the QEMU dirty-bitmap |
| 53 | + * name that currently exists on the running VM and is therefore the only valid parent |
| 54 | + * for the next incremental backup. Written by {@link #BITMAP_NAME} on each successful |
| 55 | + * backup; cleared on restore (the restored disk image has no bitmap, so the next backup |
| 56 | + * must be a fresh full). When the VM has no detail, {@code decideChain} forces full. |
| 57 | + */ |
| 58 | + public static final String VM_ACTIVE_CHECKPOINT_ID = "nas.active_checkpoint_id"; |
| 59 | + |
| 60 | + private NASBackupChainKeys() { |
| 61 | + } |
| 62 | +} |
0 commit comments