Coder Social home page Coder Social logo

cp2004 / octoprint-onedrive-backup Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 1.0 1.41 MB

Backup your OctoPrint install to OneDrive automatically

Home Page: https://plugins.octoprint.org/plugins/onedrive_backup

License: GNU Affero General Public License v3.0

JavaScript 1.13% Python 83.69% Jinja 0.03% TypeScript 14.85% Shell 0.30%
octoprint octoprint-plugin onedrive backup

octoprint-onedrive-backup's Introduction

OneDrive Backup Plugin

Automatically upload OctoPrint backups to OneDrive when they are created.

Installation

Install the plugin via the bundled Plugin Manager or manually using this URL:

https://github.com/cp2004/OctoPrint-OneDrive-Backup/releases/latest/download/release.zip

Warning: This plugin requires Python 3.7 or newer to install. To find out more about upgrading your OctoPrint install to use Python 3, you can take a look at this post

Warning 2: Don't try installing this plugin from the source code on GitHub, since it has a separate build step for the frontend code. If you are insterested in installing from source to contribute, please see the contributing guidelines

Configuration

Once the plugin is installed and loaded, you can set it up to connect to your Microsoft account.

Adding your account

Add account

Select 'Add account' to generate a login code. Head to the URL linked to login with your account, entering the code generated and logging in with your Microsoft account. Grant OctoPrint OneDrive Backup access to your files.

Once this is done, return the plugin, and it should show your account name & a success message.

Login done

Configuring the backup upload

Select Folder

You can then configure the folder to save backups to. Select 'Change Folder' and then you should be able to navigate through your OneDrive folders to find somewhere for backups to be saved.

Backup upload progress

Maybe give it a test after configuring it - head to the backup & restore tab and create a backup. Upload progress will be shown in a notification in the UI.

Important Security Notice

Please be aware that this plugin stores its tokens for accessing your Microsoft account in OctoPrint's configuration folder, as expected. As a result, if your OctoPrint install (or the server it is running on) is compromised, your files in OneDrive are at risk.

It is not recommended to use this plugin on OctoPrint installs accessible directly from the internet, or multi-user installs where you may not trust every user.

The author of this plugin is not responsible for any damage caused as a result of using this plugin.

Contributing

Please see the contributing guidelines for more information.

Sponsors

As well as 2 others supporting me regularly through GitHub Sponsors!

Supporting my efforts

GitHub Sponsors

I created this project in my spare time, and do my best to support the community with issues and help using it. If you have found this useful or enjoyed using it then please consider supporting it's development! ❤️. You can sponsor monthly or one time, for any amount you choose.

Check out my other plugins

You can see all of my published OctoPrint plugins on the OctoPrint Plugin Repository! Or, if you're feeling nosy and want to see what else I'm working on, check out my GitHub profile.

☁️

octoprint-onedrive-backup's People

Contributors

cp2004 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

appkingsoftware

octoprint-onedrive-backup's Issues

[Bug]: Installation fails with Octoprint 1.8.0 & Python 3.10.4 ... Due to Rust/MSAL versions ?

Description of the bug

Installation fails with Octoprint 1.8.0 & Python 3.10.4 ...
Due to Rust version ? and/or MSAL error ?
Please see attached logs.

pi@raspberrypi:~ $ rustc --version
rustc 1.61.0 (fe5b13d68 2022-05-18)

I have rust version 1.61.0 installed (see command line response above), yet the plugin log of the install (which fails) seems to show rust 1.30 being used, consequently it shows this error in the log.
2022-05-20 10:32:09,079 ! This package requires Rust >=1.41.0.
See the attached plugin log for more details.

Forgive me if this is a user error. This is a great plugin which I'd like to be able to install and use again.

Plugin version

1.0.1

OctoPrint version

1.8.0

OctoPrint logs

plugin_pluginmanager_console(1).log
octoprint(1).log

[Request] ensure that URLs are not logged by requests on errors

What would you like implemented?

In some cases where a network request can encounter an error, just logging the exception from requests is not good enough because this contains the URL that it was trying to access. For upload sessions, this URL is unique and while it should expire so there is no security compromise, log files shouldn't really contain stuff like this.

All access tokens used are never logged as they are securely contained in request headers.

Thought of while looking at #175

[Bug]: Uploads only when Backup made manually

Description of the bug

I use the command line backup funktion "/home/pi/oprint/bin/octoprint plugins backup:backup" after a successful print but even after restarting the pi the plugin does not recognise the newly created backup. Only when i start a backup manually in the GUI.

Plugin version

1.0.1

OctoPrint version

1.8.1

OctoPrint logs

octoprint (2).log

[Request]: Steps Clarification & Scheduled backup

What would you like implemented?

Great plugin. I really like how it handles everything automatically and hooks into the built in backup system. After installing it, I wasn't 100% certain how to perform the backup to OneDrive. I only had one option that I knew to backup the Octoprint and tried it. I saw the message informing me it was also updated to OneDrive. I wasn't certain this would happened and instead guessed. It may be worth a mention on the plugin manager page. Perhaps a button to navigate to that page? Or buttons on your plugin page to perform the backup from it directly?

Additionally, I would be great to add a function to perform the backup on a schedule. I am not sure if this is already supported natively in Octoprint. If it is, I am sure your plugin will catch the event and perform the upload. If so, disregard this idea.

No backups in the OneDrive location...

I have the OneDrive backup setup, it looks like there are no issues but when I run a backup or use backup scheduler it does not put anything in the OneDrive location. It let me setup O365 business OneDrive account without issues and said it authenticated. But I still don't get any backups.

[Request]: Rescan-Button for Folders

Cheers!

there IS the posibility i haven't seen the button. Maybe i'm just to stupid.

But a rescan-button for the OneDrive-Folders would be nice.
MAYBE even a button to create new folders?

How did i get to this point:
I linked my Octoprint instance with my OneDrive and noticed, that i should create a new folder for the Backups.
So i created the folder via OneDrive. But it did not show up until i relinked and rebootet my Octoprint-Instance.

[Bug]: Uploading Notifications

Description of the bug

When uploading a Backup to OneDrive it spams you the progress as notifications.

image

Bug or Feature?
Anyway: kinda annoying ;)
There might be a better way to solve this. Maybe something like a progessbar in one notification?
Or two notifications one saying "Currently uploading" and one Saying "i'm done!" or "Error....."

Plugin version

1.0.0.0

OctoPrint version

Version 1.7.2

OctoPrint logs

not provided

Documentation Clarifications

Below are a couple items that may be helpful to include in the documentation either inline or in a FAQ/Troubleshooting section:

  • If the request code expires while trying to Add Account, restart OctoPrint, access the OneDrive Backup plugin, and then click the Add Account button again to generate a new request code
  • After adding an account, immediately clicking the Change Folder button may result in an error; restart OctoPrint, access the OnceDrive Backup plugin, and then try again

I can create a pull request with the above, but wanted to discuss it here first in case I was just doing something incorrectly. Also, it may be possible to add buttons for the above items to retry/refresh, but I haven't had a chance to dig into the actual code yet. Thanks for the plugin and take care!

[Request]: Automatic Deletion of Previous Backups

Can the application be updated to automatically delete previous backups? I often find myself having to do this manually, and it would be more convenient if OneDrive could simply keep the last X number of updates. I'm not sure if this feature is currently available or if it's feasible to implement.

Thank you in advance!

[Bug]: ERROR - 400 Client Error: Bad Request for url

Description of the bug

I have a fresh install of the Onedrive backup plugin. I am able to add my account no issue, however whenever I try and select a folder I receive "Error:Unknown error. Check octoprint.log for details.". It stays that way until I restart octoprint, where it will error again if I try and select a folder. I have tried reinstalling the plugin and its the same result. The logs state "Client error: Bad request for URL" when trying to contact Microsoft.

Has anyone else received this? I have a personal onedrive account, and I have MFA setup as well in case that is the culprit. The MFA authentication works fine with adding the account.

Thank you in advance for any help you can provide, and I can provide any other info that may be needed.

Plugin version

1.0.0

OctoPrint version

1.7.2

OctoPrint logs

2022-01-07 13:25:30,341 - octoprint.plugins.onedrive_backup.OneDriveComm - ERROR - 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/root/children?%24select=
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_onedrive_backup/onedrive.py", line 309, in _graph_request
response.raise_for_status()
File "/home/pi/oprint/lib/python3.7/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/root/children?%24select=

[Bug]: Unable to create upload session (Bad Request)

Description of the bug

Backups don't get uploaded

Plugin version

1.0

OctoPrint version

1.7.2

OctoPrint logs

The errors from octoprint.log after the backup that was created successfully are the following. I also attach sysinfo bundle.
Can you see something that has to do with my setup?

octoprint-systeminfo-20220107183101.zip
2022-01-07 18:23:19,862 - octoprint.plugins.backup - INFO - ... done creating backup zip.
2022-01-07 18:23:19,868 - octoprint.plugins.onedrive_backup.OneDriveComm - INFO - Starting upload session for octoprint-backup-20220107-182319.zip
2022-01-07 18:23:20,726 - octoprint.plugins.onedrive_backup.OneDriveComm - ERROR - 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/items/01ZXFHCG2P45CF7E6UHRFZ3ZXTOUSZNGGO:/octoprint-backup-20220107-182319.zip:/createUploadSession
Traceback (most recent call last):
File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_onedrive_backup/onedrive.py", line 309, in _graph_request
response.raise_for_status()
File "/home/pi/oprint/lib/python3.7/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/items/01ZXFHCG2P45CF7E6UHRFZ3ZXTOUSZNGGO:/octoprint-backup-20220107-182319.zip:/createUploadSession
2022-01-07 18:23:20,731 - octoprint.plugins.onedrive_backup.OneDriveComm - ERROR - Error creating upload session: {'code': 'invalidRequest', 'message': 'Invalid request', 'innerError': {'date': '2022-01-07T16:23:20', 'request-id': '6ffcdfb8-85d5-4600-a9b1-34d4bf032e2a', 'client-request-id': '6ffcdfb8-85d5-4600-a9b1-34d4bf032e2a'}}

Use backoff to retry on errors

It would make sense to retry failed upload chunks (and other requests) at least once or twice to make sure the connection is truly dead. Sometimes it might just fail on us for a random reason, and retrying it succeeds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.