How do I enable backup with the Python API?

I create boxes with:

box, pw = client.linode.createinstance(boxtype, region, image="linode/ubuntu18.04", label=label, group=group)

How can I set enable backups on the recently created box? I see it's possible through the API but couldn't find a similar feature in the Python API.
Thank you!

1 Reply

Not sure if you can enable backups with create_instance, but you should be able to enable backups after you create it with enable_backups()

new_linode, password = client.linode.create_instance("g6-standard-1", "us-east", image="linode/debian9", label="APITest")

new_linode.enable_backups()

There's a bunch of things you can do with the new_linode object -- try using dir. It'll display a list of callable methods and attributes for an object. Here's an example:

print(dir(new_linode))

... 'alerts', 'allocate_ip', 'api_endpoint', 'api_list', 'available_backups', 'backups', 'boot', 'cancel_backups', 'clone', 'configs', 'create_config', 'create_disk', 'created', 'delete', 'disks', 'enable_backups', 'generate_root_password', 'group', 'hypervisor', 'id', 'image', 'invalidate', 'ips', 'ipv4', 'ipv6', 'kvmify', 'label', 'make', 'make_instance', 'mutate', 'properties', 'reboot', 'rebuild', 'region', 'rescue', 'save', 'shutdown', 'snapshot', 'specs', 'stats', 'stats_for', 'status', 'type', 'updated']

You can use dir on these as well:

print(dir(new_linode.backups))

... 'enabled', 'schedule']

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct