# Set policies by CLI

**URL:** <https://kopia.discourse.group/t/set-policies-by-cli/2594>\
**Category:** General Topics\
**Created:** [January 22, 2024, 5:04pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594 "2024-01-22T17:04:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erkeye](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@Erkeye](https://kopia.discourse.group/u/Erkeye)\
**Post date:** [January 22, 2024, 5:04pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/1 "2024-01-22T17:04:36Z")

</div>

Hi all.  
I’m very frustated because I feell imposible to set scheduling (cron format) policies by CLI.  
Reference just says:  
–snapshot-time-crontab Semicolon-separated crontab-compatible expressions (or ‘inherit’)

but no examples.

I have tried as is but I get sh erros:  
kopia policy set --snapshot-time-crontab _;_;_;_;\* global

Then this:  
kopia policy set --snapshot-time-crontab “_;_;_;_;\*” global

but getting this error:  
Setting policy for root@kopia:/global

- setting cron snapshot times to [\* \* \* \* _]  
ERROR scheduling policy: invalid scheduling policy: invalid cron expression "_"

Then I have tried every single conbination I have imagined for typing the cron expression and I always get the same error:  
ERROR scheduling policy: invalid scheduling policy: invalid cron expression

Examples:

“_;_;_;_;_"  
"_ \* \* \* _"  
"[_;_;_;_;_]”  
“[\* \* \* \* _]"  
[_;_;_;_;_]  
[\* \* \* \* _]  
["_;_;_;_;_”]  
[“\* \* \* \* \*”]

I have testted this cron expresion \* \* \* \* \* and others as well but always checking them first in web UI, so all of them are correct dor the web UI. In fact my first attempt was for this cron expression: 33 3 \* \* \*

What the hell I’m doing wrong? Or maybe this is a bug?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Erkeye](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@Erkeye](https://kopia.discourse.group/u/Erkeye)\
**Post date:** [January 22, 2024, 5:16pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/2 "2024-01-22T17:16:45Z")

</div>

I have realized about another problem. Setting global as target doesn’t afect the global policies but the /global directorie instead…  
but using -global as target (following reference) gives this error:  
kopia: error: unknown short flag ‘-g’, try --help

This is very frustating…

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [January 22, 2024, 5:31pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/3 "2024-01-22T17:31:36Z")

</div>

This is not a bug - you just don’t do it right.

Here how to do it:

```auto
$ kopia policy set --snapshot-time-crontab "33 3 * * *" --global

$ kopia policy set --snapshot-time-crontab "33 3 * * *;15 11 * * *" --global

```

semicolons separate multiple crontab schedules if you need more than one.

Documentation could be made more clearer. Simple example would help.

Feel free to submit PR.

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [January 22, 2024, 5:32pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/4 "2024-01-22T17:32:52Z")

</div>

`global` is a directory name

`--global` is a flag instructing to modify global policy

as per docs:

`target`  
Select a particular policy (‘user@host’,’@host’,‘user@host:path’ or a local path). Use --global to target the global policy.

`--` was truncated to `–` in docs. Again feel free to correct it.

---

<div class="post-metadata">

**Author:** ![Erkeye](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@Erkeye](https://kopia.discourse.group/u/Erkeye)\
**Post date:** [January 22, 2024, 6:59pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/6 "2024-01-22T18:59:43Z")

</div>

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Erkeye](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@Erkeye](https://kopia.discourse.group/u/Erkeye)\
**Post date:** [January 24, 2024, 4:08pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/7 "2024-01-24T16:08:57Z")

</div>

Sorry, but I cannot find file to edit and PR in the github repo. [This](https://github.com/kopia/kopia/blob/master/site/content/docs/Reference/Command-Line/_index.md) is the closest one, but I don’t find nothing for common commands…  
Can you help me about this…?

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [January 24, 2024, 5:43pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/8 "2024-01-24T17:43:52Z")

</div>

Thank you for considering improving kopia! This is the right attitude.

You can find it by clicking at links here (red circle):

 ![Screenshot 2024-01-24 at 17.42.39](https://global.discourse-cdn.com/free1/uploads/kopia/original/1X/9e4a4f5b49502d6ed66f6ebe085881e0f9963b1b.png)

---

<div class="post-metadata">

**Author:** ![Erkeye](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@Erkeye](https://kopia.discourse.group/u/Erkeye)\
**Post date:** [January 24, 2024, 9:08pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/9 "2024-01-24T21:08:11Z")

</div>

Sorry, no luck: the [link](https://github.com/kopia/kopia/edit/master/site/content/docs/Reference/Command-Line/Common/policy-set.md) for editing or view source is dead.

 ![image](https://global.discourse-cdn.com/free1/uploads/kopia/original/1X/9b7e0c62d6b5fd9053dbfb8052be7580ed78802a.png)  
I just can create an Issue…

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [January 24, 2024, 9:46pm UTC](https://kopia.discourse.group/t/set-policies-by-cli/2594/10 "2024-01-24T21:46:05Z")

</div>

You are right! oups. I am sorry for pointing you into wrong direction.

Can anybody more familiar with this repo help here please?
