Creating scheduled disk snapshots
You can configure automatic disk snapshot 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. The time is provided for the UTC
time zone. - Snapshot retention settings.
- Scheduled snapshot description and labels (you can only use the API to add them to the schedule settings).
Note
Scheduled snapshots may be created with a slight delay depending on the current load on the service.
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 drives, such as HDDs, SSDs, and non-replicated SSDs, as well as ultra-high performance network storages with three replicas (SSD).
For non-replicated SSDs and ultra-high performance network storages with three replicas (SSD), the snapshot time is not determined.
To take snapshots of local disks residing on dedicated hosts, use Yandex Cloud Backup. This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.
A quota, which can be increased, applies to the number of schedules per cloud. Fixed limits 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.
Cron expressions
You can specify a snapshot schedule using cron expressionsMinutes Hours Day-of-month Month Day-of-week
. You can also use special expressions, e.g., to create snapshots every hour or every day.
Possible field values
Field name |
Acceptable values |
Supported special characters |
---|---|---|
Minutes |
0 -59 |
, , - , * , / |
Hours |
0 -23 (UTC) |
, , - , * , / |
Day of month |
1 -31 |
, , - , * , ? , / |
Month |
1 -12 , JAN -DEC |
, , - , * , / |
Day of week |
1 -7 , MON -SUN |
, , - , * , ? , / |
Note
The names of months and days are case-insensitive, i.e., MON
is the same as mon
.
Special characters
You can use the following special characters in cron expressions:
-
*
: Select all values in the field.*
character in theHours
field: Snapshots are created every hour. -
?
: Select any field value. You cannot specifyDay of month
andDay of week
at the same time. If you entered a value or*
in one of these fields, enter?
. in the other.10
inDay of month
and?
inDay of week
: Snapshots are created every tenth day of the month. -
-
: Select a range of values.The
10-12
range inHours
: Snapshots are created at 10 a.m., 11 a.m., and 12 p.m. -
,
: Select multiple values.MON, WED, FRI
in theDay of week
field: Snapshots are created on Monday, Wednesday, and Friday. -
/
: Increment the value.2/6
inHours
: Snapshots are created at 2 a.m., 8 a.m., 2 p.m., and 8 p.m.
Examples of cron expressions
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 expression | Description | The same as |
---|---|---|
@hourly |
Snapshots are created at the start of every hour. | 0 * ? * * |
@daily @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 @annually |
Snapshots are created every year on January 1 at midnight. | 0 0 1 1 * |
Storing snapshots
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 last five snapshots, the first snapshot is deleted after the sixth one is created, the second is deleted after the seventh one is created, etc.
- Only the snapshots younger than a certain age, e.g., those created for 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 at the ACTIVE
status.
Snapshot 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 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 the
test-disk-with-a-long-name
disk is attached to thetest-vm
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
CREATING
: Schedule is being created.ACTIVE
: Schedule is on: based on it, new disk snapshots are created and old ones are deleted (if the respective parameter has been specified in snapshot retention).UPDATING
: Changes are being made to the schedule settings or the list of attached disks.INACTIVE
: Schedule has been paused, snapshots are not created or deleted.DELETING
: Schedule is being deleted.
All snapshot creation or deletion operations that started prior to changing, pausing, or deleting the schedule will be completed.