By realmag777
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 …
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!
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
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.