{ "info": { "author": "Luiz Aoqui", "author_email": "laoqui@ca.ibm.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2 :: Only", "Topic :: Database", "Topic :: System :: Archiving :: Backup", "Topic :: Utilities" ], "description": "# backwork [![Build Status](https://travis-ci.org/IBM/backwork.svg?branch=master)](https://travis-ci.org/IBM/backwork) [![PyPI version](https://badge.fury.io/py/backwork.svg)](https://badge.fury.io/py/backwork)\nBackup simplified.\n\n`backwork` is a toolkit that simplifies the process of backing up and restoring databases. It\nhandles the backup process itself as well as upload, download, restoration, and error notification.\n\n## Prerequisites\n* Python 2.7\n\n## Installing\nYou can install `backwork` using `pip`:\n```sh\n$ pip install backwork\n```\n\n## Running\nAfter installing you should have a `backwork` command available.\n```\n$ backwork --help\nusage: backwork [-h] [-n NOTIFIERS] {backup,restore,upload,download} ...\n\npositional arguments:\n {backup,restore,upload,download}\n\noptional arguments:\n -h, --help show this help message and exit\n -n NOTIFIERS, --notify NOTIFIERS\n enable a notifier, it can be used multiple times\n```\n\n## Plug-ins\nJust having `backwork` is not enough. You will need to the plug-ins that\nsuit your needs. You can install plug-ins by running:\n```sh\n$ pip install \n```\nYou can discover available plug-ins by [viewing the `backwork-plugin` topic on Github.](https://github.com/topics/backwork-plugin)\n\nPlug-ins are divided into three categories:\n\n### Backup\nBackup plug-ins are responsible for connecting to databases and doing the\nactual backup process, as well as the restore process for the backups.\nYou can discover available backup plug-ins by [viewing the `backwork-plugin-backup` topic on Github.](https://github.com/topics/backwork-plugin-backup)\n\nOnce you install a backup plug-in it will be available via the `backwork backup` and `backwork restore` commands:\n```sh\n$ backwork backup --help\nusage: backwork backup [-h] [-U] {mongo} ...\n\nPerform database backups. Run `backwork backup {database_type} -h` for more\ndetails on each supported database.\n\npositional arguments:\n {mongo}\n\noptional arguments:\n -h, --help show this help message and exit\n -U, --upload output backup data to stdout to allow piping it to an upload\n command\n```\n\n```\nusage: backwork restore [-h] [-U] {mongo} ...\n\nPerform database restores. Run `backwork restore {database_type} -h` for more\ndetails on each supported database.\n\npositional arguments:\n {mongo}\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\n\n#### Available plug-ins:\n* `backwork-backup-mongo`\n\n### Upload\nUpload plug-ins store and retrieve your backup files securely from remote storage.\nYou can discover available upload plug-ins by [viewing the `backwork-plugin-upload` topic on Github.](https://github.com/topics/backwork-plugin-upload)\n\nYou can use them with the `backwork upload`, `backwork show`, and `backwork download` commands:\n```sh\n$ backwork upload --help\nusage: backwork upload [-h] {softlayer} ...\n\nUpload a file to remote service. Run `backwork upload {service} -h` for more\ndetails on each supported service.\n\npositional arguments:\n {softlayer}\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\n```sh\n$ backwork show --help\nusage: backwork show [-h] {cos} ...\n\nShows available backups on a remote service. Run `backwork show {service} -h` for\nmore details on each supported service.\n\npositional arguments:\n {cos}\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\n```sh\n$ backwork download --help\nusage: backwork download [-h] {softlayer} ...\n\nDownload a file from a remote service. Run `backwork upload {service} -h` for more\ndetails on each supported service.\n\npositional arguments:\n {softlayer}\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\n#### Available plug-ins:\n* `backwork-upload-softlayer`\n\n### Notifiers\nNotifiers tell you when things go wrong. More important than having a backup\nprocess configured is knowing when this process fails.\nYou can discover available notifier plug-ins by [viewing the `backwork-plugin-notifier` topic on Github.](https://github.com/topics/backwork-plugin-notifier)\n\nNotifiers are enabled on the `backwork` command using the `-n` or `--notify`\narguments. They may also require some extra values, such API keys.\n\n```sh\n$ backwork --help\nusage: backwork [-h] [-n NOTIFIERS] [--sentry-dsn SENTRY_DSN]\n {backup,upload} ...\n\npositional arguments:\n {backup,upload}\n\noptional arguments:\n -h, --help show this help message and exit\n -n NOTIFIERS, --notify NOTIFIERS\n enable a notifier, it can be used multiple times\n --sentry-dsn SENTRY_DSN\n Sentry DSN to be used for notifications. It can also\n be set with the evironment variable $SENTRY_DSN.\n```\n\nYou can enable as many notifiers as you want on a command.\n\n**Available plug-ins:**\n* `backwork-notify-sentry`\n\n## Examples\n#### Backup a MongoDB database running locally\n```sh\n$ backwork backup mongo\n2017-01-15 03:58:15,270 backup.mongo INFO starting mongo backup...\n2017-01-15 03:58:15,270 backup.mongo INFO saving file to /Users/laoqui/Projects/backwork/dumps/mongo_backup_20170115-035815.archive.gz\n2017-01-15 03:58:15,350 backup.mongo INFO output:\n\n 2017-01-15T03:58:15.342-0500 writing app.products to archive '/Users/laoqui/Projects/backwork/dumps/mongo_backup_20170115-035815.archive.gz'\n 2017-01-15T03:58:15.347-0500 done dumping app.products (1 document)\n\n2017-01-15 03:58:15,350 backup.mongo INFO backup complete\n```\nThis will create an archived backup, compressed and timestamped, and stored in a\nfolder called `dumps` in the current directory.\n\n#### Backup remote MongoDB database\n```sh\n$ backwork backup mongo -h : -u -p\n```\n\n#### Backup a MongoDB to a specific folder and file name\n```sh\n$ backwork backup mongo -o /var/backups --archive=mongo_backup.archive\n```\n\n#### Upload a backup file to Softlayer ObjectStorage\n```sh\n$ backwork upload softayer -u -p -d -c /path/to/file /remote/path/location\n```\n\n#### User Sentry to receive error messages\n```sh\n$ backwork -n sentry --sentry-dsn backup mongo -o /var/backups --archive=mongo_backup.archive\n```\n\n#### More info\nCheck the `--help` information for each of the commands for more details.\n\n## Extending\nThe best way to extend `backwork` is by creating new plugi-ins. They are simple\nPython packages that implement a few set of methods. Here are some base classes\nyou can use as a starting point:\n\n```python\nclass BackupBase(object):\n \"\"\"Base class that describes the interface a backup command must implement.\n\n Attributes:\n command the value used in the command line to invoke this command,\n usually is the name of the database (e.g.: mongo, mysql)\n \"\"\"\n command = \"\"\n\n def __init__(self, args, extra):\n \"\"\"Initialize a backup command given the arguments passed to CLI\"\"\"\n self.args = args\n self.extra = extra\n\n @classmethod\n def parse_args(cls, subparsers):\n \"\"\"Parse CLI arguments specific to this subcommand\"\"\"\n raise NotImplementedError(\"Base method not overriden.\")\n\n def backup(self):\n \"\"\"Backup a database given the arguments specified.\n\n All the values passed via the CLI are available at `self.args` and\n `self.extra`. The first object stores known arguments that have been\n explicitly parsed. The second object is a list of arguments that are\n unkown to the parser and can be useful for invoking other commands\n withouht having to re-define its parser's arguments.\n\n This method should raise exceptions in case of errors so any active\n notifier can hadle it.\n \"\"\"\n raise NotImplementedError(\"Base method not overriden.\")\n\n\nclass UploadBase(object):\n \"\"\"Base class that describes the interface an upload command must implement.\n\n Attributes:\n command the value used in the command line to invoke this command,\n usually is the name of the service (e.g.: softlayer, s3)\n \"\"\"\n command = \"\"\n\n def __init__(self, args, extra):\n \"\"\"Initialize an upload command given the arguments passed to CLI\"\"\"\n self.args = args\n self.extra = extra\n\n @classmethod\n def parse_args(cls, subparsers):\n \"\"\"Parse CLI arguments specific to this subcommand\"\"\"\n raise NotImplementedError(\"Base method not overriden.\")\n\n def upload(self):\n \"\"\"Upload a file to the remote service.\n\n All the values passed via the CLI are available at `self.args` and\n `self.extra`. The first object stores known arguments that have been\n explicitly parsed. The second object is a list of arguments that are\n unkown to the parser and can be useful for invoking other commands\n withouht having to re-define its parser's arguments.\n\n This method should raise exceptions in case of errors so any active\n notifier can hadle it.\n \"\"\"\n raise NotImplementedError(\"Base method not overriden.\")\n\n\nclass NotifierBase(object):\n \"\"\"Base class for notifiers\n\n Notifiers are responsible for sending messages to external services to\n report relevant events that may happen during the execution of a command.\n\n Attributes:\n command the value used to enable a notifier in the command line,\n e.g.: `backwork -n {command}`\n \"\"\"\n command = \"\"\n\n def __init__(self, args, extra):\n self.args = args\n self.extra = extra\n\n @classmethod\n def parse_args(cls, parser):\n \"\"\"Add command line argument parsing rules relevant to the notifier.\n\n This method is not required to be implemented as it might not be\n necessary to add more arguments to the parser in some cases.\n \"\"\"\n pass\n\n def notify(self, msg=\"\"):\n \"\"\"Handle an incoming message.\n\n The `msg` object could be either a `string` or an `Exception`. You may\n want to handle them differently with something like:\n\n if issubclass(msg.__class__, Exception):\n handle_exception(msg)\n else:\n handle_string(msg)\n\n If `msg` is an exception, the call to this method will be in the context\n of an `except`, meaning you will be able to access `sys.exc_info()`.\n \"\"\"\n raise NotImplementedError(\"Base method not overriden.\")\n```\n\nTo make your package visible to `backwork` you will also need to declare an\n[`entry_point`](https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plug-ins)\nin your `setup.py` file.\n\nEach plug-in type has a different `entry_point` key:\n\n#### Backups:\n```python\nsetup(\n ...\n entry_points={\n \"backwork.backups\": [\n \"\": \"module:BackupClass\"\n ],\n \"backwork.restores\": [\n \"\": \"module:RestoreClass\"\n ]\n },\n ...\n```\n\n#### Uploads:\n```python\nsetup(\n ...\n entry_points={\n \"backwork.uploads\": [\n \"\": \"module:UploadClass\"\n ],\n \"backwork.shows\": [\n \"\": \"module:ShowClass\"\n ]\n \"backwork.downloads\": [\n \"\": \"module:DownloadClass\"\n ]\n },\n ...\n```\n\n#### Notifiers:\n```python\nsetup(\n ...\n entry_points={\n \"backwork.notifiers\": [\n \"\": \"module:NotifierClass\"\n ]\n },\n ...\n```\n\nOnce your plug-in is ready you can use `pip` to install it and it should be\navailable to be used be `backwork`.\n\n## Future work\n* Add support for more databases, storage services and notifiers\n* Handle backup scheduling\n* Support more environment variables", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ibm/backwork", "keywords": "", "license": "Apache 2", "maintainer": "", "maintainer_email": "", "name": "backwork", "package_url": "https://pypi.org/project/backwork/", "platform": "", "project_url": "https://pypi.org/project/backwork/", "project_urls": { "Homepage": "https://github.com/ibm/backwork" }, "release_url": "https://pypi.org/project/backwork/0.3.0/", "requires_dist": null, "requires_python": "", "summary": "Backup made easy.", "version": "0.3.0" }, "last_serial": 5692958, "releases": { "0.1.7": [ { "comment_text": "", "digests": { "md5": "4aac9a33bc21437aa4e06f7290e19ac4", "sha256": "22574aa5459b3d5a548055773912ea4b7928fcb61314667bec7a03b9c46d07cd" }, "downloads": -1, "filename": "backwork-0.1.7-py3-none-any.whl", "has_sig": false, "md5_digest": "4aac9a33bc21437aa4e06f7290e19ac4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12685, "upload_time": "2019-08-14T15:45:27", "url": "https://files.pythonhosted.org/packages/ae/82/6beaef6d1b677641acde9969045594b7450d2ccae7ab65b6db5970b785c7/backwork-0.1.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e406fd50d4adb45ae82abfedd2302097", "sha256": "a25c77f291a9705102097d99d74aa1f237ce6fed441a187d1bf5536e4ed6c689" }, "downloads": -1, "filename": "backwork-0.1.7.tar.gz", "has_sig": false, "md5_digest": "e406fd50d4adb45ae82abfedd2302097", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7553, "upload_time": "2019-08-14T15:45:29", "url": "https://files.pythonhosted.org/packages/37/e4/39312a4212531ddec232075c15bf95092e460813784c8bc3d4b5bf49a1e2/backwork-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "16317e8087cc1d58358c793c560b83df", "sha256": "8c031b24de5960f200055f21a74acf97c35ea1051d051922b5ecfd39f6730fd8" }, "downloads": -1, "filename": "backwork-0.1.8.tar.gz", "has_sig": false, "md5_digest": "16317e8087cc1d58358c793c560b83df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7523, "upload_time": "2019-08-14T18:04:23", "url": "https://files.pythonhosted.org/packages/49/13/3a6dd330a4fa1b0f747c6f898baa4b24595d8fd03ece0c4bd3dfd019b45b/backwork-0.1.8.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "0858d9d988196ff6624d5e846232c3d0", "sha256": "dffd78c6153c0c8fd9b52d6d8b8246e2cb012dd7991fa621e78070583dfc4f47" }, "downloads": -1, "filename": "backwork-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0858d9d988196ff6624d5e846232c3d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8658, "upload_time": "2019-08-14T20:11:58", "url": "https://files.pythonhosted.org/packages/03/fc/fc0ca36a64b1ff09ffdc8721e192eec00703f1f65f55e8949c4822700099/backwork-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "818563fc1c82fe75c707b99718e88d49", "sha256": "33b32c98a0b8f2499e2c4cced3d918c69f20353675c124466e336f2424360489" }, "downloads": -1, "filename": "backwork-0.3.0.tar.gz", "has_sig": false, "md5_digest": "818563fc1c82fe75c707b99718e88d49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11905, "upload_time": "2019-08-17T23:00:17", "url": "https://files.pythonhosted.org/packages/a1/d6/4b26c529bd436da1449ed3565221864c9c050023fe93a7bdb2577248cc56/backwork-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "818563fc1c82fe75c707b99718e88d49", "sha256": "33b32c98a0b8f2499e2c4cced3d918c69f20353675c124466e336f2424360489" }, "downloads": -1, "filename": "backwork-0.3.0.tar.gz", "has_sig": false, "md5_digest": "818563fc1c82fe75c707b99718e88d49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11905, "upload_time": "2019-08-17T23:00:17", "url": "https://files.pythonhosted.org/packages/a1/d6/4b26c529bd436da1449ed3565221864c9c050023fe93a7bdb2577248cc56/backwork-0.3.0.tar.gz" } ] }