Question

Apply weekly backup plan to the servlet using API

Hello

I have a question about how to apply weekly backup plan to the servlets created automatically

 const droplet = await client.droplets.create({
            name: domain,
            region: 'ams3',
            size: 's-1vcpu-1gb',
            image: snapshot_id,
            ssh_keys: [await this.get_ssh_key()],
            backups: true,
            plan: 'weekly',
            ipv6: false,
            private_networking: true,
            volumes: null,
            tags: ['test'],
            user_data
        });
        

Field ‘plan’ doesn work in this context

Thank you …


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 10, 2025
Accepted Answer

Hey @realmag777 👋

You’re almost there! The reason plan isn’t working is because it needs to be part of the backup_policy object, not a top-level field.

You can find that information in the API docs here:

https://docs.digitalocean.com/reference/api/digitalocean/#tag/Droplets/operation/droplets_create

Here’s how to update your code:

const droplet = await client.droplets.create({
  name: domain,
  region: 'ams3',
  size: 's-1vcpu-1gb',
  image: snapshot_id,
  ssh_keys: [await this.get_ssh_key()],
  backups: true,
  backup_policy: {
    plan: 'weekly',
    weekday: 'SUN',
    hour: 4
  },
  ipv6: false,
  private_networking: true,
  volumes: null,
  tags: ['test'],
  user_data
});

- Bobby

alexdo
Site Moderator
Site Moderator badge
April 10, 2025

Heya, @realmag777

On top of what’s already mentioned, you can use the API to check the backup status like this:

const dropletInfo = await client.droplets.get(droplet.id); console.log(dropletInfo.backup_ids); // Will list backup IDs if enabled

Regards

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.