0

Clone a Linode

by
Published Oct 17, 2025

You can clone your Linode's existing Disks or Configuration profiles to another Linode on your Account.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Clone a Linode
7
 * You can clone your Linode's existing Disks or Configuration profiles to another Linode on your Account.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  linodeId: string,
13
  body: {
14
    backups_enabled?: false | true;
15
    configs?: number[];
16
    disks?: number[];
17
    group?: string;
18
    label?: string;
19
    linode_id?: number;
20
    metadata?: { user_data?: string };
21
    placement_group?: { id: number };
22
    private_ip?: false | true;
23
    region?: string;
24
    type?: string;
25
  },
26
) {
27
  const url = new URL(
28
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/clone`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "POST",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Bearer " + auth.token,
36
    },
37
    body: JSON.stringify(body),
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45