[Yandex Cloud documentation](../../index.md) > [Yandex Compute Cloud](../index.md) > [Concepts](index.md) > Disks and file storages > Creating scheduled snapshots

# Creating scheduled disk snapshots


You can configure automatic [disk snapshot](snapshot.md) creation based on a _schedule_.

In the schedule, you specify:

* Disks for which the snapshots will be created. One schedule can include multiple disks, and one disk can be added to multiple schedules.
* Frequency of snapshot creation by hour, day, week, or [cron expression](#cron). All times are [UTC±00:00](https://en.wikipedia.org/wiki/UTC±00:00).
* [Snapshot retention](#retention) settings.
* Scheduled snapshot description and [labels](../../resource-manager/concepts/labels.md) (you can only use the API to add them to the schedule settings).

{% note info %}

Scheduled snapshots may be created with a slight delay depending on the current Compute Cloud load.

{% endnote %}

Snapshots are created in the same folder as the schedule, even if the schedule has disks from other folders.

A single snapshot can only be created for one disk at a time. All other schedules for the disk in question are ignored until a snapshot for this disk is created.

You can create snapshots of network [disks](disk.md#disks_types) and drives, such as HDDs, SSDs, and non-replicated SSDs, as well as ultra high-speed network storages with three replicas (SSD).

For non-replicated SSDs and ultra high-speed network storages with three replicas (SSD), the snapshot time is not determined.

To create snapshots of local disks residing on [dedicated hosts](dedicated-host.md), use [Yandex Cloud Backup](../../backup/index.md). This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.

A [quota](limits.md#compute-quotas), which can be increased, applies to the number of schedules per cloud. Fixed [limits](limits.md#compute-limits-snapshot-schedule) apply to the number of disks in a schedule and the number of schedules for a disk.

Schedules can be used free of charge. You only pay for storing the snapshots. For more information, see [Compute Cloud pricing policy](../pricing.md).


## Cron expressions {#cron}

You can specify a snapshot schedule using a [cron expression](https://en.wikipedia.org/wiki/Cron) consisting of five [fields](#cron-fields): `Minutes Hours Day-of-month Month Day-of-week`. You can also use [special expressions](#cron-predefined), e.g., to create snapshots every hour or every day.


### Possible field values {#cron-fields}

| Name <br>name | Acceptable <br>values | Supported <br>[special <br>characters](#cron-special-characters) |
|----|----|----|
|`Minutes` | `0`–`59` | `,`, `-`, `*`, `/` |
|`Hours` | `0`–`23` (UTC+0)| `,`, `-`, `*`, `/` |
|`Day of month`| `1`–`31` | `,`, `-`, `*`, `?`, `/` |
|`Month`| `1`–`12` <br>`JAN`–`DEC` | `,`, `-`, `*`, `/` |
|`Day of week`| `1`–`7` <br>`MON`–`SUN` | `,`, `-`, `*`, `?`, `/` |

{% note info %}

The names of and days are case-insensitive, i.e., `MON` is the same as `mon`.

{% endnote %}


### Special characters {#cron-special-characters}

You can use the following special characters in cron expressions:

* `*`: Select all values in the field.

  > `*` character in the `Hours` field: Snapshots are created every hour.

* `?`: Select any field value. You cannot specify `Day of month` and `Day of week` at the same time. If you entered a value or `*` in one of these fields, enter `?` in the other.

  > `10` in `Day of month` and `?` in `Day of week`: Snapshots are created every tenth day of the month.

* `-`: Select a range of values.

  > The `10-12` range in `Hours`: Snapshots are created at 10 a.m., 11 a.m., and 12 p.m.

* `,`: Select multiple values.

  > `MON, WED, FRI` in the `Day of week` field: Snapshots are created on Monday, Wednesday, and Friday.

* `/`: Increment the value.

  > `2/6` in `Hours`: Snapshots are created at 2 a.m., 8 a.m., 2 p.m., and 8 p.m.


### Examples of cron expressions {#cron-examples}

| Cron expression | Description |
|----|----|
| `0 * ? * *` | Snapshots are created at the start of every hour. |
| `15 10 ? * *` | Snapshots are created every day at 10:15 a.m. |
| `0 9,18 ? * 1-5` | Snapshots are created every weekday at 9 a.m. and 9 p.m. |


### Special expressions {#cron-predefined}

| Cron expression | Description | The same as |
| --- | --- | --- |
| `@hourly` | Snapshots are created at the start of every hour. | `0 * ? * *` |
| `@daily`<br>`@midnight` | Snapshots are created every day at midnight. | `0 0 ? * *` |
| `@weekly` | Snapshots are created every Sunday at midnight. | `0 0 * * SUN` |
| `@monthly` | Snapshots are created every first day of the month at midnight. | `0 0 1 * *` |
| `@yearly`<br>`@annually` | Snapshots are created every year on January 1 at midnight. | `0 0 1 1 *` |


## Storing snapshots {#retention}

With schedules, you can set and configure a _snapshot retention policy_. For each disk included in a schedule, you can store:

* All created scheduled snapshots.
* Only the last few snapshots. The oldest snapshots created on schedule are automatically deleted once the specified number is exceeded. For example, if you want to keep only the most recent five snapshots, the first snapshot will only be deleted after the sixth one is created, the second snapshot will be deleted after the seventh one is created, and so on.
* Only the snapshots younger than a certain age, e.g., those created during the last few days. The oldest snapshots created on schedule are automatically deleted once the specified age is reached.

The retention policy applies to all disks in a schedule.

Snapshots are deleted only while the schedule is active (its [status](#statuses) is `ACTIVE`).


## Snapshot names {#names}

For a scheduled snapshot, a name up to 63 characters long is generated. The name consists of the following items separated with underscores:

* Name of a virtual machine the disk is attached to (up to 24 characters) or the `unattached` line if the disk is not attached to any VM.
* Disk name (up to 20 characters).
* Snapshot creation date and time (UTC) in `YYYYMMDDhhmm` format (year, month, day, hour, and minute).
* Line consisting of four random alphanumeric characters.

> For example, if `test-disk-with-a-long-name` is attached to `test-vm`, its scheduled snapshot created on September 1, 2022 at 03:30 p.m. UTC will have the following name: 
> 
> ```
> test-vm_test-disk-with-a-lon_202209011530_pd2k
> ```

## Schedule statuses {#statuses}

* `CREATING`: Schedule is being created.
* `ACTIVE`: Schedule is active: it is used to create new disk snapshots and delete the old ones (if you selected the relevant option in the [snapshot retention](#retention) settings).
* `UPDATING`: Schedule settings or the list of attached disks are being updated.
* `INACTIVE`: Schedule has been paused, snapshots are not created or deleted.
* `DELETING`: Schedule is being deleted.

All running snapshot creation or deletion operations initiated prior to changing, disabling, or deleting the schedule will be completed.

#### See also {#see-also}

* [Guides on disk snapshots and schedules](../operations/index.md#snapshots)