dobackup


Namedobackup JSON
Version 2.3.1 PyPI version JSON
download
home_pagehttps://github.com/jotyGill/digitalocean-backup/
SummaryAutomated Offline Or Live Snapshots Of Digitalocean Droplets
upload_time2020-09-16 06:08:03
maintainer
docs_urlNone
authorJGill
requires_python>=3.5
licenseGNU General Public License v3 or later (GPLv3+)
keywords backup automated-backup digitalocean digital-ocean backups automation digitalocean-backup snapshots
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dobackup
<p align="center">
<a href="https://pepy.tech/project/dobackup"><img alt="Downloads" src="https://pepy.tech/badge/dobackup"></a> </p>
Simple Automated offline snapshots of digitalocean droplets utilising [python-digitalocean](https://github.com/koalalorenzo/python-digitalocean).
The script safely shutdowns a given droplet or all droplets with a give tag then performs snapshots of them, Then
it turns them back on. Every step is logged as well as displayed in the console output.
The script is designed to be used as a cron job as well. If any error occurs the script logs it then exits with
exit code of 1. Very useful feature to ensure that the backups are successfully completed. I use it to delete older
backups only if new one is successful and to use a 'healthchecks' service to get notified if a backup failed.
(see cron examples)

![dobackup](https://user-images.githubusercontent.com/8462091/67843798-96c57d00-faf4-11e9-8ce1-5596bf422a44.gif)

## Installation
Install as a user without sudo. This installs it in ~/.local/bin/ make sure this path is in your $PATH.
``` bash
python3 -m pip install --user -U dobackup
```
If not found, add the following to your .bashrc or .zshrc
``` bash
# Add to PATH to Install and run programs with "pip install --user"
export PATH=$PATH:~/.local/bin
```

## Usage

### Initialise
Store the api access token in .token file by running '--init' and providing the token string.
``` bash
dobackup --init
# Paste the digitalocean token string, press enter
# If you have multiple accounts, paste each- press enter, so on
# When done, just press enter to submit an empty string
# The sequence of these tokens (0,1,2) will be later used to "use" the tokens
```
To use one of the stored tokens, specify it's index after "dobackup ",
``` bash
dobackup 0      # 0 is implicit
dobackup 1      # will use token 1
dobackup 2      # will use token 2
```

### Display Information
Display Information about droplets and snapshots using --list commands.
Examples
``` bash
dobackup --list-droplets
dobackup --list-snaps
dobackup --list-backups  # snaps created using this tool
dobakcup --list-older_than 7    # lists backup taken by dobackup that are older than 7 days
dobackup --list-tags
dobackup --list-tagged   # list tagged servers with the tag 'dobackup'

```

### Use Tags (optional)
Use tags to backup multiple servers at ones. Use existing tags or create new.
Default tag is 'dobackup' .
To tag a server with a 'dobakup' tag.
``` bash
dobackup --tag-server ubuntu-18-04  # '--tag-name dobackup' is implicit
```
To tag a server with 'web-servers' tag.
``` bash
dobackup --tag-server ubuntu-18-04  --tag-name web-servers
```
NOTE: In 2.0, --'tag-name'-- is appended to the backup name, instead of hardcoded str '--dobackup--'.
The default value of tag_name is still 'dobackup'. Now we can use --tag-name along with --list-backups, --list-older-than,
--delete-older-than. Now we can keep the backups of droplets with lets say 'tag1' for 5 days and 'tag2' for 10 days.
example command. "--delete-older-than 5 --tag-name 'tag1'" ,   "--delete-older-than 10 --tag-name 'tag2'"


### Perform Backups
To backup a server using it's name or id.
``` bash
dobackup --backup ubuntu-18-04
dobackup --backup 1929129
dobackup --live-backup ubuntu-18-04       # live backup, backup without shutting down the vm
dobackup --backup ubuntu-18-04 --keep     # this won't be deleted with '--delete-older-than'
```

To backup all servers that have a given tag.
``` bash
dobackup --backup-all   # --tag-name dobackup    is implicit
dobackup --backup-all --tag-name web-servers
```
To set a cron job, to backup all 'tagged' servers and auto delete old backups, if backups were successful
``` bash
0 1 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7
```

Using amazing utility [healthchecks](https://github.com/healthchecks/healthchecks). to get notified if an error occurred during the process.
``` bash
0 1 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7 && wget -O/dev/null https://hc-ping.com/your-string
```

### Perform Restore
To restore a server using it's name or id and snapshot's name or id
``` bash
dobackup --restore-droplet ubuntu-18-04 --restore-to "ubuntu-18-04--dobackup--2018-06-01 14:36:07"
```

### Delete Old Backups
To delete a specific snapshot.
``` bash
dobackup --delete-snap "ubuntu-1gb-sgp1-01--dobackup--2018-05-31 17:43:11"   # put snap name or id
dobackup --delete-snap "111111111,222222222,3333333333"     # comma seperated multiple ids or names
```

To delete all old backups taken with dobackup.
``` bash
# delete snapshots older than 14 days with '--dobackup--' in their names
# WILL NOT delete snapshots with '--dobackup-keep--' in their names
dobackup --delete-older-than 14
```

## Options

``` bash
usage: dobackup [-h] [-v] [--init] [-l] [--list-backups] [-s] [--list-tagged]
                [--list-tags] [--list-older-than LIST_OLDER_THAN]
                [--backup BACKUP] [--backup-all] [--live-backup LIVE_BACKUP]
                [--live-backup-all] [--tag-droplet TAG_DROPLET]
                [--untag-droplet UNTAG_DROPLET] [--tag-name TAG_NAME]
                [--delete-older-than DELETE_OLDER_THAN]
                [--delete-snap DELETE_SNAP] [--shutdown SHUTDOWN]
                [--powerup POWERUP] [--restore-droplet RESTORE_DROP]
                [--restore-to RESTORE_TO] [--keep]
                [token_id]

Automated Offline Or Live Snapshots Of Digitalocean Droplets

positional arguments:
  token_id              Specify token number to be used, default=0, supply
                        only if you have multiple Digitalocean accounts

optional arguments:
  -h, --help            show this help message and exit
  -v, -V, --version     show programs version number and exit
  --init                Save token to .token file
  --tag-name TAG_NAME   To be used with "--list-tags", "--tag-droplet" and "--
                        backup-all", default value is "dobackup"
  --keep                To keep backups for long term. "--delete-older-than"
                        wont delete these. To be used with "--backup","--
                        backup-all"

Informational Args:
  Arguments That Display Information

  -l, --list-droplets   List all droplets
  --list-backups        List all snapshots with "dobackup" in their name
  -s, --list-snaps      List all snapshots
  --list-tagged         List droplets using "--tag-name"
  --list-tags           List all used tags
  --list-older-than LIST_OLDER_THAN
                        List snaps older than, in days

Backup Args:
  Arguments That Backup Or Restore Droplets

  --backup BACKUP       Shutdown, Backup (snapshot), Then Restart the droplet
                        with given name or id
  --backup-all          Shutdown, Backup (snapshot), Then Restart all droplets
                        with the given "--tag-name"
  --live-backup LIVE_BACKUP
                        Backup (snapshot), the droplet with given name or id,
                        without shutting it down
  --live-backup-all     Backup (snapshot), all droplets with the given "--tag-
                        name", without shutting them down
  --restore-droplet RESTORE_DROP
                        Restore, the droplet with given name or id
  --restore-to RESTORE_TO
                        Snapshot id or name, to restore the droplet to

Action Args:
  Arguments That Perform Actions

  --tag-droplet TAG_DROPLET
                        Add tag to the provided droplet name or id
  --untag-droplet UNTAG_DROPLET
                        Remove tag from the provided droplet name or id
  --delete-older-than DELETE_OLDER_THAN
                        Delete backups older than, in days
  --delete-snap DELETE_SNAP
                        Snapshot(s) by name or id. e.g --delete-snap 111111 or
                        --delete-snap '111111,222222,333333'
  --shutdown SHUTDOWN   Shutdown, the droplet with given name or id
  --powerup POWERUP     Powerup, the droplet with given name or id

```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jotyGill/digitalocean-backup/",
    "name": "dobackup",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "backup,automated-backup,digitalocean,digital-ocean,backups,automation,digitalocean-backup,snapshots",
    "author": "JGill",
    "author_email": "joty@mygnu.org",
    "download_url": "https://files.pythonhosted.org/packages/71/b1/996d4f336e4655f9eb6d4054c57a13e94e95a3de0cb2ce0c97bca5378e8b/dobackup-2.3.1.tar.gz",
    "platform": "GNU/Linux",
    "description": "# dobackup\n<p align=\"center\">\n<a href=\"https://pepy.tech/project/dobackup\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/dobackup\"></a> </p>\nSimple Automated offline snapshots of digitalocean droplets utilising [python-digitalocean](https://github.com/koalalorenzo/python-digitalocean).\nThe script safely shutdowns a given droplet or all droplets with a give tag then performs snapshots of them, Then\nit turns them back on. Every step is logged as well as displayed in the console output.\nThe script is designed to be used as a cron job as well. If any error occurs the script logs it then exits with\nexit code of 1. Very useful feature to ensure that the backups are successfully completed. I use it to delete older\nbackups only if new one is successful and to use a 'healthchecks' service to get notified if a backup failed.\n(see cron examples)\n\n![dobackup](https://user-images.githubusercontent.com/8462091/67843798-96c57d00-faf4-11e9-8ce1-5596bf422a44.gif)\n\n## Installation\nInstall as a user without sudo. This installs it in ~/.local/bin/ make sure this path is in your $PATH.\n``` bash\npython3 -m pip install --user -U dobackup\n```\nIf not found, add the following to your .bashrc or .zshrc\n``` bash\n# Add to PATH to Install and run programs with \"pip install --user\"\nexport PATH=$PATH:~/.local/bin\n```\n\n## Usage\n\n### Initialise\nStore the api access token in .token file by running '--init' and providing the token string.\n``` bash\ndobackup --init\n# Paste the digitalocean token string, press enter\n# If you have multiple accounts, paste each- press enter, so on\n# When done, just press enter to submit an empty string\n# The sequence of these tokens (0,1,2) will be later used to \"use\" the tokens\n```\nTo use one of the stored tokens, specify it's index after \"dobackup \",\n``` bash\ndobackup 0      # 0 is implicit\ndobackup 1      # will use token 1\ndobackup 2      # will use token 2\n```\n\n### Display Information\nDisplay Information about droplets and snapshots using --list commands.\nExamples\n``` bash\ndobackup --list-droplets\ndobackup --list-snaps\ndobackup --list-backups  # snaps created using this tool\ndobakcup --list-older_than 7    # lists backup taken by dobackup that are older than 7 days\ndobackup --list-tags\ndobackup --list-tagged   # list tagged servers with the tag 'dobackup'\n\n```\n\n### Use Tags (optional)\nUse tags to backup multiple servers at ones. Use existing tags or create new.\nDefault tag is 'dobackup' .\nTo tag a server with a 'dobakup' tag.\n``` bash\ndobackup --tag-server ubuntu-18-04  # '--tag-name dobackup' is implicit\n```\nTo tag a server with 'web-servers' tag.\n``` bash\ndobackup --tag-server ubuntu-18-04  --tag-name web-servers\n```\nNOTE: In 2.0, --'tag-name'-- is appended to the backup name, instead of hardcoded str '--dobackup--'.\nThe default value of tag_name is still 'dobackup'. Now we can use --tag-name along with --list-backups, --list-older-than,\n--delete-older-than. Now we can keep the backups of droplets with lets say 'tag1' for 5 days and 'tag2' for 10 days.\nexample command. \"--delete-older-than 5 --tag-name 'tag1'\" ,   \"--delete-older-than 10 --tag-name 'tag2'\"\n\n\n### Perform Backups\nTo backup a server using it's name or id.\n``` bash\ndobackup --backup ubuntu-18-04\ndobackup --backup 1929129\ndobackup --live-backup ubuntu-18-04       # live backup, backup without shutting down the vm\ndobackup --backup ubuntu-18-04 --keep     # this won't be deleted with '--delete-older-than'\n```\n\nTo backup all servers that have a given tag.\n``` bash\ndobackup --backup-all   # --tag-name dobackup    is implicit\ndobackup --backup-all --tag-name web-servers\n```\nTo set a cron job, to backup all 'tagged' servers and auto delete old backups, if backups were successful\n``` bash\n0 1 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7\n```\n\nUsing amazing utility [healthchecks](https://github.com/healthchecks/healthchecks). to get notified if an error occurred during the process.\n``` bash\n0 1 * * * ~/.local/bin/dobackup --backup-all && ~/.local/bin/dobackup --delete-older-than 7 && wget -O/dev/null https://hc-ping.com/your-string\n```\n\n### Perform Restore\nTo restore a server using it's name or id and snapshot's name or id\n``` bash\ndobackup --restore-droplet ubuntu-18-04 --restore-to \"ubuntu-18-04--dobackup--2018-06-01 14:36:07\"\n```\n\n### Delete Old Backups\nTo delete a specific snapshot.\n``` bash\ndobackup --delete-snap \"ubuntu-1gb-sgp1-01--dobackup--2018-05-31 17:43:11\"   # put snap name or id\ndobackup --delete-snap \"111111111,222222222,3333333333\"     # comma seperated multiple ids or names\n```\n\nTo delete all old backups taken with dobackup.\n``` bash\n# delete snapshots older than 14 days with '--dobackup--' in their names\n# WILL NOT delete snapshots with '--dobackup-keep--' in their names\ndobackup --delete-older-than 14\n```\n\n## Options\n\n``` bash\nusage: dobackup [-h] [-v] [--init] [-l] [--list-backups] [-s] [--list-tagged]\n                [--list-tags] [--list-older-than LIST_OLDER_THAN]\n                [--backup BACKUP] [--backup-all] [--live-backup LIVE_BACKUP]\n                [--live-backup-all] [--tag-droplet TAG_DROPLET]\n                [--untag-droplet UNTAG_DROPLET] [--tag-name TAG_NAME]\n                [--delete-older-than DELETE_OLDER_THAN]\n                [--delete-snap DELETE_SNAP] [--shutdown SHUTDOWN]\n                [--powerup POWERUP] [--restore-droplet RESTORE_DROP]\n                [--restore-to RESTORE_TO] [--keep]\n                [token_id]\n\nAutomated Offline Or Live Snapshots Of Digitalocean Droplets\n\npositional arguments:\n  token_id              Specify token number to be used, default=0, supply\n                        only if you have multiple Digitalocean accounts\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v, -V, --version     show programs version number and exit\n  --init                Save token to .token file\n  --tag-name TAG_NAME   To be used with \"--list-tags\", \"--tag-droplet\" and \"--\n                        backup-all\", default value is \"dobackup\"\n  --keep                To keep backups for long term. \"--delete-older-than\"\n                        wont delete these. To be used with \"--backup\",\"--\n                        backup-all\"\n\nInformational Args:\n  Arguments That Display Information\n\n  -l, --list-droplets   List all droplets\n  --list-backups        List all snapshots with \"dobackup\" in their name\n  -s, --list-snaps      List all snapshots\n  --list-tagged         List droplets using \"--tag-name\"\n  --list-tags           List all used tags\n  --list-older-than LIST_OLDER_THAN\n                        List snaps older than, in days\n\nBackup Args:\n  Arguments That Backup Or Restore Droplets\n\n  --backup BACKUP       Shutdown, Backup (snapshot), Then Restart the droplet\n                        with given name or id\n  --backup-all          Shutdown, Backup (snapshot), Then Restart all droplets\n                        with the given \"--tag-name\"\n  --live-backup LIVE_BACKUP\n                        Backup (snapshot), the droplet with given name or id,\n                        without shutting it down\n  --live-backup-all     Backup (snapshot), all droplets with the given \"--tag-\n                        name\", without shutting them down\n  --restore-droplet RESTORE_DROP\n                        Restore, the droplet with given name or id\n  --restore-to RESTORE_TO\n                        Snapshot id or name, to restore the droplet to\n\nAction Args:\n  Arguments That Perform Actions\n\n  --tag-droplet TAG_DROPLET\n                        Add tag to the provided droplet name or id\n  --untag-droplet UNTAG_DROPLET\n                        Remove tag from the provided droplet name or id\n  --delete-older-than DELETE_OLDER_THAN\n                        Delete backups older than, in days\n  --delete-snap DELETE_SNAP\n                        Snapshot(s) by name or id. e.g --delete-snap 111111 or\n                        --delete-snap '111111,222222,333333'\n  --shutdown SHUTDOWN   Shutdown, the droplet with given name or id\n  --powerup POWERUP     Powerup, the droplet with given name or id\n\n```",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "Automated Offline Or Live Snapshots Of Digitalocean Droplets",
    "version": "2.3.1",
    "split_keywords": [
        "backup",
        "automated-backup",
        "digitalocean",
        "digital-ocean",
        "backups",
        "automation",
        "digitalocean-backup",
        "snapshots"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "8654c597e358f27ef9508c9807c096cb",
                "sha256": "93e02d11c01571ed0c7233a6ea1ded3649a0b428cb8ba70505cd98a3fda74a7a"
            },
            "downloads": -1,
            "filename": "dobackup-2.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8654c597e358f27ef9508c9807c096cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 16198,
            "upload_time": "2020-09-16T06:08:03",
            "upload_time_iso_8601": "2020-09-16T06:08:03.296695Z",
            "url": "https://files.pythonhosted.org/packages/71/b1/996d4f336e4655f9eb6d4054c57a13e94e95a3de0cb2ce0c97bca5378e8b/dobackup-2.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-16 06:08:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "jotyGill",
    "error": "Could not fetch GitHub repository",
    "lcname": "dobackup"
}
        
Elapsed time: 0.16229s