Hi,
I would need to apply a retention policy as follow:
- 1 snapshot by day for the last 7 days
- 1 snapshot by month after that
Is it currently possible to do so with the Kopia retention policy by CLI ? I’m not too sur how the retention policy works with kopia
That’s actually close to the default behavior, which will keep last 7 days of snapshots (of which last 48 yours will have hourly precision and 10 latest no matter how frequently they are done). After that Kopia will keep 4 weekly snapshots and 24 monthly snapshots after that and will drop down to annual snapshots.
Here’s a snapshot history of one of my directories using default policy that shows what’s being retained and why. As you can see one latest snapshot of each hour, day, week, month, year is retained and you can specify how many to keep using retention policies. All other snapshots are forgotten as more eligible “latest” snapshot for a given time becomes available:
2019-12-31 23:43:04 PST k21b5ad2d14629db56924500d50c8fc90 673 MB dr-xr-xr-x files:7214 dirs:1519 (annual-3,monthly-20)
2020-01-31 23:43:11 PST k730377da1da11f9ca1c6d2b0c828a2d1 680.2 MB dr-xr-xr-x files:7214 dirs:1519 (monthly-19)
2020-02-29 23:43:07 PST k35c0c2c9f014e72f6c767a4782ac15e3 678.7 MB dr-xr-xr-x files:7210 dirs:1515 (monthly-18)
2020-03-31 23:43:46 PDT k6fd162bedf8854b5727f7b95c21640fc 676.4 MB drwxr-xr-x files:7211 dirs:1515 (monthly-17)
2020-04-30 23:43:08 PDT ke5c0e2089892e8ef676b9e3dfa74c9e2 681.6 MB drwxr-xr-x files:7213 dirs:1515 (monthly-16)
2020-05-31 23:43:16 PDT kbbbf1b2e8013782a00d0c2cf1064949d 84.8 MB drwxr-xr-x files:21 dirs:13 (monthly-15)
2020-06-30 23:43:06 PDT kf38ba2429b70cc057e269023f2f83dfc 79.1 MB drwxr-xr-x files:22 dirs:13 (monthly-14)
2020-07-31 23:43:18 PDT k0279ac1d881a0ba786b4768f6b888057 84.4 MB drwxr-xr-x files:22 dirs:13 (monthly-13)
2020-08-31 23:43:11 PDT k9fcc9ce461731e1a7bef4e1cb228e473 80.2 MB drwxr-xr-x files:23 dirs:13 (monthly-12)
2020-09-30 23:43:13 PDT k96997342ac1496e23f8c2dc5fdcbe38e 83.2 MB drwxr-xr-x files:23 dirs:13 (monthly-11)
2020-10-31 23:43:08 PDT k6f719c3d2de5c843b8b37332c73e064c 89.9 MB drwxr-xr-x files:23 dirs:13 (monthly-10)
2020-11-30 23:43:13 PST k9c55a0939418aa17cb74dec7afc6a164 82.5 MB drwxr-xr-x files:25 dirs:13 (monthly-9)
2020-12-31 23:43:05 PST k0f88a58ad7a4504834725f2c411af11d 85.4 MB drwxr-xr-x files:25 dirs:13 (annual-2,monthly-8)
2021-01-31 23:43:14 PST k4c2f9dd7dd5c52c1c85d59b7a4dd188a 87.4 MB drwxr-xr-x files:25 dirs:13 (monthly-7)
2021-02-28 23:43:05 PST k19948d37d6a620116635671112106969 1.2 GB drwxr-xr-x files:33 dirs:17 (monthly-6)
2021-03-31 23:43:11 PDT k8459023d81bef073fa4d1709a2a4bcb7 1.2 GB drwxr-xr-x files:35 dirs:17 (monthly-5)
2021-04-30 23:43:06 PDT k41059b3d8af43ec520018d2a87b4142d 1.2 GB drwxr-xr-x files:36 dirs:17 (monthly-4)
2021-05-31 23:43:07 PDT kf128544257e3c780e89c97ccd275d485 1.2 GB drwxr-xr-x files:36 dirs:17 (monthly-3)
2021-06-27 23:43:10 PDT k9970a421a03324aee5a577f1b4e7f403 1.2 GB drwxr-xr-x files:36 dirs:17 (weekly-4)
2021-06-30 23:43:09 PDT kb85c67c43abbd500c398fde9215ce576 1.2 GB drwxr-xr-x files:35 dirs:17 (monthly-2)
2021-07-04 23:43:06 PDT kcd227cb021a93ecf3566e115c332c102 1.2 GB drwxr-xr-x files:35 dirs:17 (weekly-3)
2021-07-06 23:43:06 PDT kb99e67cbdfd774b4c474b4751d30bcf4 1.2 GB drwxr-xr-x files:35 dirs:17 (daily-7)
2021-07-07 23:43:13 PDT k6ba199d2d868e40a423d63c7833864c2 1.2 GB drwxr-xr-x files:35 dirs:17 (daily-6)
2021-07-08 23:43:13 PDT k0ebf32d6e629fafc121cc9fb073123e3 1.2 GB drwxr-xr-x files:36 dirs:17 (daily-5)
2021-07-09 23:43:14 PDT ke5d786f11cbecfa0c5dabe6e9af5d1e8 1.2 GB drwxr-xr-x files:36 dirs:17 (daily-4)
2021-07-10 08:43:07 PDT k4cda8fa7d3c63953f1efacfbe46a6510 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-48)
2021-07-10 09:43:16 PDT k6aa4b3093ac75bfa50febaad8c7aa56b 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-47)
2021-07-10 10:43:02 PDT k32fa57b2157150b717ca5c65fcb0dafa 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-46)
2021-07-10 11:43:07 PDT k94033a4ef666f0bf77684b2d86ac8fce 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-45)
2021-07-10 12:43:03 PDT k373a85f4831ca73010c65ccc7a372072 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-44)
2021-07-10 13:43:12 PDT k44b4523c83483c4558b8ad25c63e8a90 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-43)
2021-07-10 14:43:07 PDT k3972b5f8b5daf1a9c7202ede5296124c 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-42)
2021-07-10 15:43:12 PDT k0bb619fe639adc29a68277361bda569f 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-41)
2021-07-10 16:43:09 PDT k63c75974bd2eefa41558012ae2321538 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-40)
2021-07-10 17:43:03 PDT k5d6d55a063188bf224307858a4eb7716 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-39)
2021-07-10 18:43:04 PDT k78554ff3b0e4f75c00f0c298447f90d4 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-38)
2021-07-10 19:43:06 PDT k94e47ef6bf3725b6eb1b0ed98e223bd8 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-37)
2021-07-10 20:43:03 PDT k4e3ac01e0c5d8024dcbb41d1f160764b 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-36)
2021-07-10 21:43:13 PDT k87690fee748904dbc366eb0f1acab64a 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-35)
2021-07-10 22:43:07 PDT kd0679bbf7155db66a84bbf5417c317ae 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-34)
2021-07-10 23:43:13 PDT k575c51cfbea67a2f49fc6f6d273b26f0 1.2 GB drwxr-xr-x files:35 dirs:17 (daily-3,hourly-33)
2021-07-11 00:43:06 PDT k87d21bfbe256e3cc428ba04fef09b4f3 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-32)
2021-07-11 01:43:15 PDT k336a894fccb199342630a525852a177e 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-31)
2021-07-11 02:43:03 PDT k2207d18fcc38e32031702e32b83a2f93 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-30)
2021-07-11 03:43:09 PDT k4bec8ad2f9c5c4b3a222106b97404fe9 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-29)
2021-07-11 04:43:11 PDT k712b4160e6eecccde804f53057dbbc50 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-28)
2021-07-11 05:43:04 PDT k5fa861716cbac2175e9829053ffde7b4 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-27)
2021-07-11 06:43:01 PDT kf176149df97f8b3c3220e0408f62662d 1.2 GB drwxr-xr-x files:35 dirs:17 (hourly-26)
2021-07-11 07:43:05 PDT k23a496a7482b64ac6495575ffad9de17 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-25)
2021-07-11 08:43:12 PDT k0456968255435e582ee2a7ca7d5a22c4 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-24)
2021-07-11 09:43:03 PDT kee6ebf12e286653dbc8554d3372ec273 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-23)
2021-07-11 10:43:08 PDT kd3db1f0636694e3fb862f0153dcb8dc8 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-22)
2021-07-11 11:43:08 PDT k70ecf6b84f11067b4622e76012d1c81f 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-21)
2021-07-11 12:43:04 PDT kf4747f0ba49c769ca9283310c964ad6f 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-20)
2021-07-11 13:43:11 PDT kb3b5da3503ee59b5ac62bfbe6864e082 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-19)
2021-07-11 14:43:15 PDT ka3b823d6999571840235a4e5a5fb8aa4 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-18)
2021-07-11 15:43:08 PDT kc6fbb36b024d507b96cddadfb1776ae8 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-17)
2021-07-11 16:43:14 PDT k7e88ee64f7298a4e197d1750a3a05110 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-16)
2021-07-11 17:43:10 PDT k92aca85b29111086a52ac723d75fc6ed 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-15)
2021-07-11 18:43:15 PDT k14013082898d0199705b3004ca2b0cfd 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-14)
2021-07-11 19:43:04 PDT kcbaf098c36ab7db9cf8c758f06dd6de3 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-13)
2021-07-11 20:43:10 PDT kf05930b67f06231d7642a98510f5d2a4 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-12)
2021-07-11 21:43:03 PDT k94c1e1248712d102878c0a3f84b495bb 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-11)
2021-07-11 22:43:12 PDT kba7b703e49d28104acd33b40d8a82840 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-10)
2021-07-11 23:43:06 PDT kd5e61641112eb7a33bfd7da5211adac5 1.2 GB drwxr-xr-x files:36 dirs:17 (weekly-2,daily-2,hourly-9)
2021-07-12 00:43:07 PDT k55ac28c14d630fcec598d5ba9c8acd74 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-8)
2021-07-12 01:43:07 PDT k7382e12ab04d1a56af8db3a2a729703c 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-7)
2021-07-12 02:43:05 PDT ka14f77176dcfc9742a743af763701725 1.2 GB drwxr-xr-x files:36 dirs:17 (hourly-6)
2021-07-12 03:22:06 PDT ka14f77176dcfc9742a743af763701725 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-10)
2021-07-12 03:43:03 PDT ka14f77176dcfc9742a743af763701725 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-9,hourly-5)
2021-07-12 04:22:07 PDT ka14f77176dcfc9742a743af763701725 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-8)
2021-07-12 04:43:01 PDT ka14f77176dcfc9742a743af763701725 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-7,hourly-4)
2021-07-12 05:22:07 PDT k8e445efb58c2763da16a3193cf44fcda 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-6)
2021-07-12 05:43:08 PDT k8d3ba0a831b8bb79038ca9bef96461a7 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-5,hourly-3)
2021-07-12 06:22:03 PDT k8d3ba0a831b8bb79038ca9bef96461a7 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-4)
2021-07-12 06:43:07 PDT k7ebde835e3cb23c02ce024d1d4c97fd3 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-3,hourly-2)
2021-07-12 07:22:10 PDT k6f953aae65c1ee4efa48d4d469bae782 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-2)
2021-07-12 07:43:11 PDT k6f953aae65c1ee4efa48d4d469bae782 1.2 GB drwxr-xr-x files:36 dirs:17 (latest-1,annual-1,monthly-1,weekly-1,daily-1,hourly-1)
You can change the number of snapshots for each time period using:
kopia policy set --keep-daily=X --keep-hourly=Y ...
and so on.
Thanks for your answer, I think I just understood better how the kopia retention works.