Python API for DigitalOcean v2.0 REST API
Project description
# Dio (DigitalOcean python api)
##### Python API for DigitalOcean v2.0 REST API
### How to install
You can install dio using **pip**
pip install -U dio
or via sources:
python setup.py install
--
### Features
* **DROPLET BACKUP!!! (rsync and snapshot a droplet)**
* **Uses digitalocean v2.0 API**
* Running API call count
* Running API remaining call count
* All objects have a details function to return properties and values
* Get user's Droplets
* Get user's Images (Snapshot and Backups)
* Get public Images
* Create and Remove a Droplet
* Resize a Droplet
* Shutdown, restart and boot a Droplet
* Power off, power on and "power cycle" a Droplet
* Perform Snapshot
* Enable/Disable automatic Backups
* Restore root password of a Droplet
--
### Example cronjob:
```sh
# DigitalOcean backup script
0 * * * * /usr/bin/python /Users/username/bin/backup.py
```
--
### Example backup script:
```python
import dio
""" Your digitalocean API v2.0 token """
token = "YOUR_TOKEN"
""" Optional ignore list of droplets to bypass in operations """
ignore = ["dev.example.com"]
"""
Droplet backup options. Only needed for dio.Backup(options, droplet)
• ssh_user - the user account that connects to the droplet via ssh
• ssh_key - the local ssh key file (~/.ssh/rsakey)
• backup_dir - the local droplet backup directory
• remote_dirs - droplet directories to rsync
• excludes - exclude keywords from rsync
• snapshot_hour - the hour of day to shutdown and snapshot the droplet
• snapshots - number of snapshots to keep
• use_ip - use droplet ip to connect instead of droplet name
"""
options = {
"dev.example.com": {
"ssh_user" : "root",
"ssh_key" : "rsakey",
"remote_dirs" : [
"/root", "/home", "/etc", "/src",
"/usr/local", "/usr/share", "/usr/bin",
"/usr/sbin", "/var/backups", "/var/mail",
"/var/log", "/var/www",
],
"excludes" : [ "man3", ],
"snapshot_hour" : 5,
"snapshots" : 5,
"use_ip" : True,
},
"production.example.com": {
"ssh_user" : "root",
"ssh_key" : "ssh_key",
"backup_dir" : "/Users/username/Droplets",
"remote_dirs" : [ "/var/www", "/etc/nginx" ],
"excludes" : [ "wpcf7_captcha", "cache" ],
"use_ip" : False,
"snapshot_hour" : 3,
"snapshots" : 7,
}
}
""" Backs up your droplets with rsync and does a daily snapshot """
manager = dio.Manager(token, ignore)
for droplet in manager.droplets:
dio.Backup( options, droplet )
```
--
### Changelog
#### v0.3.10
- hotfix changed requests[security] back to requests
#### v0.3.9
- requires requests[security] now
#### v0.3.8
- ratelimit check fix
#### v0.3.7
- sanity checks
#### v0.3.6
- returned data checks
#### v0.3.5
- quick fix for droplet size property
#### v0.3.4 [Omachonu Ogali](https://github.com/oogali)
- Create getter and setter for sizes
- Load sizes from either class constructor or on-demand
- Set the appropriate size object via filter
- Pass our sizes to droplet class (to avoid additional, unnecessary API calls)
#### v0.3.3
- code seperation
- added actions properties to droplet and image
- added name() to image
#### v0.3.2
- added rsync excludes to options
- moved .token to .__token
#### v0.3.1
- version number bug in init
#### v0.3.0
- fixed bug in ssh_remote_dir check
- moved to a single src file
- even less api calls then before
- less ssh_remote_dir checks
- moved all class details() func to a @property
- backup log markdown improvements
- backup log lets you know if remote_dir does not exist
#### v0.2.10
- better backup time in log
- changed droplet.snapshot to not start with "@"
- backup droplet.snapshot starts with "@"
- code cleanup for Backup.py
- added @properties to Manager and Droplet for lazy instantiation
- uses even less api calls
#### v0.2.9
- fixed variable bug in backup
#### v0.2.8
- better support for github flavored markdown in backup log
#### v0.2.7
- removed log entries for empty rsync
#### v0.2.6
- changed backup log to markdown
#### v0.2.5
- fixed delete backup snapshot to only delete snapshots created by backup
- fixed manager.get_all_images() to get paginated results
- changed backup option remote_dir to remote_dirs[] so you can rsync multiple directories
- better backup logging
#### v0.2.4
- removed auto droplet population from Manager.droplets
#### v0.2.3
- hidden token from .details() data
#### v0.2.2
- changed Droplet.snapshot() to use shutdown instead of power_off.
#### v0.2.1
- added check to Backup.rsync() to make sure the droplet is on
#### v0.2
- added full backup function to Backup.py class.
- added backup prompt for Droplet.delete(). Pass in False to bypass prompt
- renamed package from python-dio to dio
##### Python API for DigitalOcean v2.0 REST API
### How to install
You can install dio using **pip**
pip install -U dio
or via sources:
python setup.py install
--
### Features
* **DROPLET BACKUP!!! (rsync and snapshot a droplet)**
* **Uses digitalocean v2.0 API**
* Running API call count
* Running API remaining call count
* All objects have a details function to return properties and values
* Get user's Droplets
* Get user's Images (Snapshot and Backups)
* Get public Images
* Create and Remove a Droplet
* Resize a Droplet
* Shutdown, restart and boot a Droplet
* Power off, power on and "power cycle" a Droplet
* Perform Snapshot
* Enable/Disable automatic Backups
* Restore root password of a Droplet
--
### Example cronjob:
```sh
# DigitalOcean backup script
0 * * * * /usr/bin/python /Users/username/bin/backup.py
```
--
### Example backup script:
```python
import dio
""" Your digitalocean API v2.0 token """
token = "YOUR_TOKEN"
""" Optional ignore list of droplets to bypass in operations """
ignore = ["dev.example.com"]
"""
Droplet backup options. Only needed for dio.Backup(options, droplet)
• ssh_user - the user account that connects to the droplet via ssh
• ssh_key - the local ssh key file (~/.ssh/rsakey)
• backup_dir - the local droplet backup directory
• remote_dirs - droplet directories to rsync
• excludes - exclude keywords from rsync
• snapshot_hour - the hour of day to shutdown and snapshot the droplet
• snapshots - number of snapshots to keep
• use_ip - use droplet ip to connect instead of droplet name
"""
options = {
"dev.example.com": {
"ssh_user" : "root",
"ssh_key" : "rsakey",
"remote_dirs" : [
"/root", "/home", "/etc", "/src",
"/usr/local", "/usr/share", "/usr/bin",
"/usr/sbin", "/var/backups", "/var/mail",
"/var/log", "/var/www",
],
"excludes" : [ "man3", ],
"snapshot_hour" : 5,
"snapshots" : 5,
"use_ip" : True,
},
"production.example.com": {
"ssh_user" : "root",
"ssh_key" : "ssh_key",
"backup_dir" : "/Users/username/Droplets",
"remote_dirs" : [ "/var/www", "/etc/nginx" ],
"excludes" : [ "wpcf7_captcha", "cache" ],
"use_ip" : False,
"snapshot_hour" : 3,
"snapshots" : 7,
}
}
""" Backs up your droplets with rsync and does a daily snapshot """
manager = dio.Manager(token, ignore)
for droplet in manager.droplets:
dio.Backup( options, droplet )
```
--
### Changelog
#### v0.3.10
- hotfix changed requests[security] back to requests
#### v0.3.9
- requires requests[security] now
#### v0.3.8
- ratelimit check fix
#### v0.3.7
- sanity checks
#### v0.3.6
- returned data checks
#### v0.3.5
- quick fix for droplet size property
#### v0.3.4 [Omachonu Ogali](https://github.com/oogali)
- Create getter and setter for sizes
- Load sizes from either class constructor or on-demand
- Set the appropriate size object via filter
- Pass our sizes to droplet class (to avoid additional, unnecessary API calls)
#### v0.3.3
- code seperation
- added actions properties to droplet and image
- added name() to image
#### v0.3.2
- added rsync excludes to options
- moved .token to .__token
#### v0.3.1
- version number bug in init
#### v0.3.0
- fixed bug in ssh_remote_dir check
- moved to a single src file
- even less api calls then before
- less ssh_remote_dir checks
- moved all class details() func to a @property
- backup log markdown improvements
- backup log lets you know if remote_dir does not exist
#### v0.2.10
- better backup time in log
- changed droplet.snapshot to not start with "@"
- backup droplet.snapshot starts with "@"
- code cleanup for Backup.py
- added @properties to Manager and Droplet for lazy instantiation
- uses even less api calls
#### v0.2.9
- fixed variable bug in backup
#### v0.2.8
- better support for github flavored markdown in backup log
#### v0.2.7
- removed log entries for empty rsync
#### v0.2.6
- changed backup log to markdown
#### v0.2.5
- fixed delete backup snapshot to only delete snapshots created by backup
- fixed manager.get_all_images() to get paginated results
- changed backup option remote_dir to remote_dirs[] so you can rsync multiple directories
- better backup logging
#### v0.2.4
- removed auto droplet population from Manager.droplets
#### v0.2.3
- hidden token from .details() data
#### v0.2.2
- changed Droplet.snapshot() to use shutdown instead of power_off.
#### v0.2.1
- added check to Backup.rsync() to make sure the droplet is on
#### v0.2
- added full backup function to Backup.py class.
- added backup prompt for Droplet.delete(). Pass in False to bypass prompt
- renamed package from python-dio to dio
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dio-0.3.10.tar.gz
(13.1 kB
view details)
File details
Details for the file dio-0.3.10.tar.gz
.
File metadata
- Download URL: dio-0.3.10.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03f9d4e946c463b57967d016422f08d7aa155a3f9258a8bde5e04e3b518dc811 |
|
MD5 | 7cb350d82100a57e7ac79b983ebe94f5 |
|
BLAKE2b-256 | f541f443bb5aee9a275d464d6f2d2e2c681619350671d0b1e4be4ec29d627064 |