{"id":308003,"date":"2020-08-05T09:00:40","date_gmt":"2020-08-05T09:00:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=308003"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=308003","title":{"rendered":"\u041a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 snapshot&#8217;\u043e\u0432 \u0438 \u0438\u0445 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513884\/\">\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0448\u043b\u043e 2 \u0434\u043d\u044f. \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u044f\u043d\u0434\u0435\u043a\u0441 \u043e\u0431\u043b\u0430\u043a\u0430 \u0432 \u042f\u043d\u0434\u0435\u043a\u0441 \u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c, \u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  Yandex.Cloud<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: <\/p>\n<p>  \u041f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c SNAPSHOT \u0434\u0438\u0441\u043a\u043e\u0432 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 instance. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0434\u0438\u0441\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u0442. <\/p>\n<p>  \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>Snapshot\u2019\u044b \u0441\u0442\u0430\u0440\u0448\u0435 n \u0434\u043d\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c n.<\/li>\n<li>Snapshot\u2019\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0432\u0438\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443:\n<pre><code class=\"plaintext\">%\u0438\u043c\u044f \u0434\u0438\u0441\u043a\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430%-\u0434\u0430\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f%-%\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0434\u0438\u0441\u043a\u0430%<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0447\u0435\u0433\u043e \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b. (\u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c bash \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0425\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  \u0412 Y.cloud \u043d\u0435\u0442 \u0448\u0442\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0439 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u0441\u0447\u0435\u0442 function \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u043e\u0433\u043e Y.cloud, \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f snapshot\u2019\u043e\u0432 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 NodeJS12<\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;); const FOLDER_ID = process.env.FOLDER_ID; async function handler(event, context) {     const snapshotService = new ycsdk.SnapshotService();     const diskService = new ycsdk.DiskService();     const diskList = await diskService.list({         folderId: FOLDER_ID,     });     for (const disk of diskList.disks) {         if ('snapshot' in disk.labels) {             snapshotService.create({                 folderId: FOLDER_ID,                 diskId: disk.id             });         }     } } exports.handler = handler; <\/code><\/pre>\n<p>  *\u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0443\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c FODLER_ID \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. <\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e. \u0418 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430.<\/p>\n<p>  \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0430 1.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e NodeJS12<br \/>  \u041b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b: \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u0442\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f snapshot\u2019a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0430\u0442\u043e\u0439 \u0438 n \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u043c\u0438\u0442\u0430 \u2013 \u0443\u0434\u0430\u043b\u044f\u0435\u043c.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, <a href=\"https:\/\/cloud.yandex.ru\/docs\/compute\/api-ref\/Snapshot\/index\">\u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 CreatedAt \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0442\u0438\u043f string.<\/p>\n<p>  \u041e\u043a. \u041f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0434\u0430\u043b\u0438\u0442 snapshot\u2019\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043b\u043e\u0436\u0435 1 \u0447\u0430\u0441\u0430 \u043e\u0442 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f (\u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430). \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0438\u0447\u0435\u0433\u043e. \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0438\u0447\u0435\u0433\u043e. \u041d\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u043e\u043b\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u043e \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f 1.<\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;);  const FOLDER_ID = process.env.FOLDER_ID;  const date = new Date(); date.setHours( date.getHours() - 1 );  async function handler(event, context) {   const snapshotService = new ycsdk.SnapshotService();    const {snapshots} = await snapshotService.list({folderId: FOLDER_ID});   for ( let snapshot in snapshots ) {     const dateSnapshot = new Date( snapshot.createdAt );     if ( dateSnapshot.getTime() &gt; date.getTime() ) snapshotService.delete({snapshotId: snapshot.id});   } }  exports.handler = handler; <\/code><\/pre>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f 2.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432 \u0442\u0435\u043b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u044b\u0432\u0435\u043b\u0430 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. <\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;);  const FOLDER_ID = process.env.FOLDER_ID;  const date = new Date(); date.setHours( date.getHours() - 1 );  async function handler(event, context) {   const snapshotService = new ycsdk.SnapshotService();    const {snapshots} = await snapshotService.list({folderId: FOLDER_ID});   throw Error( JSON.stringify( snapshots ) ); }  exports.handler = handler;  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u043e\u0442\u0432\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443: \u00ab&quot;errorMessage&quot;: &quot;[{\\&quot;labels\\&quot;:{},\\&quot;productIds\\&quot;:[],\\&quot;id\\&quot;:\\&quot;fd813o0n3p753lhqphie\\&quot;,\\&quot;folderId\\&quot;:\\&quot;b1gfub3omefcfvchsd0f\\&quot;,\\&quot;createdAt\\&quot;:{\\&quot;seconds\\&quot;:{\\&quot;low\\&quot;:1594137358,\\&quot;high\\&quot;:0,\\&quot;unsigned\\&quot;:false}},\\&quot;diskSize\\&quot;:{\\&quot;low\\&quot;:1073741824,\\&quot;high\\&quot;:0,\\&quot;unsigned\\&quot;:false},\\&quot;status\\&quot;:2,\\&quot;sourceDiskId\\&quot;:\\&quot;ef3ivjn6340h9e8incbq\\&quot;},\u2026..\u00bb<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0447\u0435\u0441\u0430\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"plaintext\">{     &quot;labels&quot;: {},     &quot;productIds&quot;: [],     &quot;id&quot;: &quot;fd813o0n3p753lhqphie&quot;,     &quot;folderId&quot;: &quot;b1gfub3omefcfvchsd0f&quot;,     &quot;createdAt&quot;: {       &quot;seconds&quot;: {         &quot;low&quot;: 1594137358,         &quot;high&quot;: 0,         &quot;unsigned&quot;: false       }<\/code><\/pre>\n<p>  \u041e\u0442\u0441\u044e\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. CreatedAt \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u0430, \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f3.<\/p>\n<p>  \u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 CreatedAt. \u041c\u0435\u043d\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;);  const FOLDER_ID = process.env.FOLDER_ID;  const date = new Date(); date.setHours( date.getHours() - 1 );  async function handler(event, context) {   const snapshotService = new ycsdk.SnapshotService();    const {snapshots} = await snapshotService.list({folderId: FOLDER_ID});   for ( let snapshot in snapshots ) {      if ( snapshot.createdAt.seconds.low &gt; date.getTime() \/ 1000 ) {       snapshotService.delete({snapshotId: snapshot.id});     }   } }  exports.handler = handler;<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"javascript\">{     &quot;errorMessage&quot;: &quot;Cannot read property 'seconds' of undefined&quot;,     &quot;errorType&quot;: &quot;TypeError&quot;,     &quot;stackTrace&quot;: [         {             &quot;function&quot;: &quot;Runtime.handler&quot;,             &quot;file&quot;: &quot;\/function\/code\/index.js&quot;,             &quot;line&quot;: 14,             &quot;column&quot;: 29         }     ]<\/code><\/pre>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u0437\u044f\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e seconds \u0443 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0445\u043e\u0442\u044f \u0440\u0430\u043d\u0435\u0435 \u043c\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0438 \u0432\u044b\u0432\u043e\u0434 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0442\u0432\u0435\u0442\u0430<code> &quot;createdAt&quot;:{&quot;seconds&quot;:{&quot;low&quot;:1594137358,&quot;high&quot;:0,&quot;unsigned&quot;:false}}<\/code><br \/>  \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f 4.<\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;);  const FOLDER_ID = process.env.FOLDER_ID;  const date = new Date(); date.setHours( date.getHours() - 1 );  async function handler(event, context) {   const snapshotService = new ycsdk.SnapshotService();    const {snapshots} = await snapshotService.list({folderId: FOLDER_ID});   for ( let i = 0; i &lt; 5; i++ ) {     throw Error( JSON.stringify( snapshots[i].createdAt ) );   }  }  exports.handler = handler;<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"plaintext\">{     &quot;errorMessage&quot;: &quot;{\\&quot;seconds\\&quot;:{\\&quot;low\\&quot;:1594137358,\\&quot;high\\&quot;:0,\\&quot;unsigned\\&quot;:false}}&quot;,     &quot;errorType&quot;: &quot;Error&quot;,     &quot;stackTrace&quot;: [         {             &quot;function&quot;: &quot;Runtime.handler&quot;,             &quot;file&quot;: &quot;\/function\/code\/index.js&quot;,             &quot;line&quot;: 13,             &quot;column&quot;: 11         }     ] }<\/code><\/pre>\n<p>  \u0421\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438 \u0446\u0438\u043a\u043b \u0434\u043e 5 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430.<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f 5.<\/p>\n<pre><code class=\"javascript\">const ycsdk = require(&quot;yandex-cloud\/api\/compute\/v1&quot;);  const FOLDER_ID = process.env.FOLDER_ID;  const date = new Date(); date.setHours( date.getHours() - 1 );  async function handler(event, context) {   const snapshotService = new ycsdk.SnapshotService();    const {snapshots} = await snapshotService.list({folderId: FOLDER_ID});   const list = [];   list.push( date.getTime() \/ 1000 );   for ( let i in snapshots ) {     const d = new Date( snapshots[i].createdAt );     list.push( d.getTime() \/ 1000 );   }   throw Error( JSON.stringify( list ) );  }  exports.handler = handler; ;<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"plaintext\">{     &quot;errorMessage&quot;: &quot;[1594135869.705,null,null,null,null,null,null,null]&quot;,     &quot;errorType&quot;: &quot;Error&quot;,     &quot;stackTrace&quot;: [         {             &quot;function&quot;: &quot;Runtime.handler&quot;,             &quot;file&quot;: &quot;\/function\/code\/index.js&quot;,             &quot;line&quot;: 18,             &quot;column&quot;: 9         }     ] } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043e\u0442\u0432\u0435\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f Date \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u044f\u043a\u043e\u0431\u044b \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 createdAt, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e \u2014 \u0432 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u042f\u043d\u0434\u0435\u043a\u0441 \u041e\u0431\u043b\u0430\u043a\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0435\u043b. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0434\u0435\u043d\u044c.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/513884\/\"> https:\/\/habr.com\/ru\/post\/513884\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513884\/\">\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0448\u043b\u043e 2 \u0434\u043d\u044f. \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u044f\u043d\u0434\u0435\u043a\u0441 \u043e\u0431\u043b\u0430\u043a\u0430 \u0432 \u042f\u043d\u0434\u0435\u043a\u0441 \u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c, \u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  Yandex.Cloud<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: <\/p>\n<p>  \u041f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c SNAPSHOT \u0434\u0438\u0441\u043a\u043e\u0432 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 instance. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0434\u0438\u0441\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u0442. <\/p>\n<p>  \u041f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>Snapshot\u2019\u044b \u0441\u0442\u0430\u0440\u0448\u0435 n \u0434\u043d\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c n.<\/li>\n<li>Snapshot\u2019\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0432\u0438\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443:\n<pre><code class=\"plaintext\">%\u0438\u043c\u044f \u0434\u0438\u0441\u043a\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430%-\u0434\u0430\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f%-%\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0434\u0438\u0441\u043a\u0430%<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0447\u0435\u0433\u043e \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b. (\u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c bash \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-308003","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308003"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/308003\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}