Skip to content

Commit f35454a

Browse files
feat(docs): backup, document --retention-lock-mode=event-based-hold
Fixes https://scylladb.atlassian.net/browse/CLOUD-3224
1 parent c587931 commit f35454a

1 file changed

Lines changed: 72 additions & 6 deletions

File tree

docs/source/backup/retention-lock.rst

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Retention Lock
33
==============
44

55
ScyllaDB Manager can protect snapshot files from accidental or malicious deletion
6-
by applying object-level retention locks on snapshot files stored in backup bucket.
6+
by applying object retention locks or event based holds on snapshot files stored in backup bucket.
77
When retention lock is enabled, snapshot files in the backup location cannot be
88
deleted until the retention period expires.
99

@@ -16,7 +16,10 @@ Retention lock is currently supported for :doc:`Google Cloud Storage <setup-gcs>
1616
How It Works
1717
============
1818

19-
When retention lock is enabled on a backup task, ScyllaDB Manager applies object-level retention
19+
Object retention lock modes (``unlocked``, ``locked``)
20+
------------------------------------------------------
21+
22+
When object retention lock is enabled on a backup task, ScyllaDB Manager applies object-level retention
2023
to all snapshot files from given backup task execution. This includes schema files, SSTable files,
2124
and manifest files. The retention lock is applied during dedicated stage (``RETENTION_LOCK``) that
2225
runs after backup is finalized and all snapshot files are already in backup location.
@@ -27,14 +30,51 @@ contained in the snapshot tag, and lasts for the specified retention days.
2730
This means that a snapshot with ``--retention-days 30`` will have its files protected for exactly 30 days
2831
from when the snapshot was taken, regardless of how long the backup task takes to complete.
2932

33+
This approach results in making a per-file request for both newly uploaded and deduplicated files.
34+
When making highly deduplicated backups to a colder storage tier (low storage costs, high request costs),
35+
consider using ``event-based-hold`` mode which avoids making additional requests for deduplicated files.
36+
37+
Event based hold mode (``event-based-hold``)
38+
--------------------------------------------
39+
40+
This mode utilizes the following cloud provider features for protecting snapshot files:
41+
42+
* `Default bucket event based holds <https://docs.cloud.google.com/storage/docs/object-holds#default-holds>`_ - uploaded
43+
objects have event based hold set. This hold needs to be removed before protected object can be deleted.
44+
* `Bucket retention lock <https://docs.cloud.google.com/storage/docs/bucket-lock>`_ - removing event based hold from an
45+
object starts specified retention period during which the object can't be deleted.
46+
47+
ScyllaDB Manager utilizes those bucket features in the following way:
48+
49+
* Newly uploaded snapshot files automatically have event based hold applied.
50+
* Deduplicated snapshot files keep their hold.
51+
* Files referenced by previous snapshot which are not a part of the current one have their event based holds released. This starts their retention period.
52+
53+
The retention period is configured via bucket configuration, not the ``--retention-days`` or ``--retention`` flags.
54+
ScyllaDB Manager won't attempt to purge stale snapshots according to backup task retention policy,
55+
if they are still protected by either event based holds or already started retention period.
56+
57+
The main benefit of this approach is that it makes only a single per-file request and does not repeat those requests for deduplicated files.
58+
When making highly deduplicated backups to a colder storage tier (low storage costs, high request costs),
59+
it's possible that the request costs can dominate the overall backup costs.
60+
``event-based-hold`` mode aims to reduce costs in such scenarios.
61+
62+
Note that since the holds for previous snapshot are released only during the backup task execution,
63+
corresponding files won't be removed from the backup storage for at least ``bucket_retention_period + backup_task_interval``.
64+
65+
Note that because all objects uploaded to the bucket are subject to the default retention policy,
66+
files coming from aborted backups, temporary manifests and permission check files can't be removed
67+
until their holds are released and the retention period expires.
68+
3069
Modes
3170
=====
3271

33-
Retention lock supports three modes controlled by the :ref:`sctool backup --retention-lock-mode <sctool-backup>` flag:
72+
Retention lock supports the following modes controlled by the :ref:`sctool backup --retention-lock-mode <sctool-backup>` flag:
3473

3574
* ``disabled`` (default): No retention lock is applied to snapshot files.
3675
* ``unlocked``: Retention lock is applied but can be shortened or removed with special permissions (see `Prerequisites`_).
3776
* ``locked``: Retention lock is applied and cannot be overridden. Once set, the lock cannot be removed or shortened, even by the bucket owner.
77+
* ``event-based-hold``: While referenced by the newest snapshot, files are protected by default event based holds. After that, they are protected by default retention period.
3878

3979
Override Lock
4080
=============
@@ -56,19 +96,30 @@ Prerequisites
5696

5797
.. group-tab:: Google Cloud Storage
5898

59-
.. rubric:: Bucket configuration
99+
.. rubric:: Bucket configuration for ``unlocked`` and ``locked`` modes
60100

61101
The GCS bucket used as the backup location must have **Object Retention** enabled.
62102
Refer to the `Enable and use object retention configurations documentation <https://docs.cloud.google.com/storage/docs/using-object-lock>`_
63103
for instructions on creating a bucket with Object Retention enabled.
64104

105+
.. rubric:: Bucket configuration for ``event-based-hold`` mode
106+
107+
The GCS bucket used as the backup location must have a **default retention policy** configured -
108+
it defines the protection period of snapshot files (see `How It Works`_).
109+
Refer to the `Use and lock retention policies <https://docs.cloud.google.com/storage/docs/using-bucket-lock#set-policy>`_
110+
for instructions on setting a default retention policy on a bucket.
111+
112+
It is also recommended to enable the **default event based hold** option on the bucket,
113+
so that the initial request setting the hold can be avoided.
114+
Refer to the `Use object holds <https://docs.cloud.google.com/storage/docs/holding-objects#set-default-hold>`_ for details.
115+
65116
.. rubric:: Permissions
66117

67118
The GCS service account used by ScyllaDB Manager Agent must have the following permissions
68119
on the backup bucket:
69120

70121
* ``storage.objects.update`` — required for updating object metadata.
71-
* ``storage.objects.setRetention`` — required for applying retention locks to snapshot files.
122+
* ``storage.objects.setRetention`` — required for applying retention locks to snapshot files in ``unlocked`` and ``locked`` modes.
72123
* ``storage.objects.overrideUnlockedRetention`` — required when using the ``--override-retention-lock`` flag
73124
to modify or remove existing locks in ``unlocked`` mode.
74125

@@ -97,11 +148,18 @@ You can also :ref:`update an existing backup task <backup-update>` to enable ret
97148
98149
sctool backup update -c <cluster ID> <backup task ID> --retention-lock-mode unlocked --retention-days 14
99150
100-
Note that when retention lock is enabled:
151+
Note that when ``unlocked`` or ``locked`` retention lock mode is enabled:
101152

102153
* ``--retention-days`` should be set to a positive value.
103154
* Count-based ``--retention`` should not be set.
104155

156+
The ``event-based-hold`` mode can be combined with any retention policy, but the most intuitive
157+
configuration is to set ``--retention-days`` to the same value as the bucket's retention period:
158+
159+
.. code-block:: none
160+
161+
sctool backup -c <cluster ID> -L gcs:<bucket> --retention-lock-mode event-based-hold --retention-days <bucket retention period days>
162+
105163
Changing retention lock configuration
106164
-------------------------------------
107165

@@ -115,6 +173,14 @@ deviating from them may lead to errors during the purge stage (see `Shared files
115173
* In ``locked`` mode, ``--retention-days`` should only be **increased**, not decreased.
116174
* Decreasing ``--retention-days`` in ``unlocked`` mode should be accompanied by the ``--override-retention-lock`` flag (see `Override Lock`_).
117175

176+
.. warning::
177+
178+
Changing the retention lock mode between ``unlocked``/``locked`` and ``event-based-hold``
179+
(in either direction) is **not supported**. These approaches to protecting snapshot files
180+
are not compatible with each other and require different bucket configurations.
181+
To switch between them, create a new backup task pointing to a different backup location
182+
configured for the desired mode.
183+
118184
Shared files
119185
============
120186

0 commit comments

Comments
 (0)