dizda / CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, Amazon S3, GoogleDrive, etc.)
MIT License
196 stars 57 forks source link

Added support to Dropbox official API #76

Closed dafuer closed 8 years ago

dafuer commented 8 years ago

Hi @dizda ,

After analysing my alternatives to back up my application, I have discovered that the best is Dropbox (in my case, the backups files are so big and my shared host has really limited capabilities). As you know dropbox-uploader is not working and it happens too frequently. I tried to configure gauffrette with dropbox but I exhausted the memory quickly (because it reads the content of file from memory) and I forced to split the file in many of them really small... So, I have decided to do tests with official dropbox API. Finally, I have implemented a client. Taking into account this client there are three ways to upload a backup to Dropbox:

1) dropbox-uploader: easy but not stable 2) Gauffrette: complex and it use a lot of memory forcing you to split files 3) using official Dropbox API which should be easy and stable.

Please, have a look at the alternative and tell me what do you think.

Cheers.

dizda commented 8 years ago

That's the perfect feature! There is a way to automatically get the access token?

dafuer commented 8 years ago

Hi @dizda ,

I don't see any automatic way to get the token. We could implement a command to simplify the process but in my opinion, the easiest way is to use an script from sdk.

First of all you need to create a new application in your dropbox account. There, you can get "key" and "secret" and using the script downloaded with the dependencies:

vendor/dropbox/dropbox-sdk/examples/authorize.php

you can easily get the token. This is what I did.

dizda commented 8 years ago

Ok will try, if we could make a command to automatically get/register the access token, it could be great! I can take care of that if you want.

dafuer commented 8 years ago

It is easy and perhaps it is better to write good documentation than create a command which we have to maintain. I don't know, I have overwork and maybe it is the reason why I'm so lazy... :) If after checking the client and the process to get a token you find the courage to develop a command, please do it! I will help you.

dizda commented 8 years ago

Ok I just tested and it works like a charm!

We can get the AuthToken directly from the Dropbox AppConsole's site, so it's pretty straightforward! I think we should also remove the old method, to avoid the confusion with too many different ways to do it, what do you think? If so, I'll release it as new major version.

dizda commented 8 years ago

Apart from that, could you throw an exception if the user has setted the dropbox_api in the config.yml, when the dropbox sdk is missing?

It's already made for Google Drive https://github.com/dizda/CloudBackupBundle/blob/master/DependencyInjection/DizdaCloudBackupExtension.php#L41

Thanks!

dafuer commented 8 years ago

Hi,

I agree with remove the old method. This method has many advantages compared to the another one. I think the best is to keep different name in this (dropbox_sdk) to make the difference with the old one (even if that is going to be removed).

I will add the exception, if you are not in hurry. If you want to do it in same work effort than release a major tag, please, feel free to do it ;)

Cheers,

dizda commented 8 years ago

Cool! Thanks I'll wait for the rest then, and I'll merge your feature, thanks for that :+1:

dizda commented 8 years ago

I made some changes in your PR, would be great if you merge https://github.com/dafuer/CloudBackupBundle/pull/1 :-)