Backup Destinations
Dropbox
A guide on how to set up Dropbox as a cloud destination for Craft Remote Backup
Not Working
This isn't currently working due to recent changes with Dropbox's API
Overview
Dropbox is relatively easy to configure. You need to create a new app via their developer dashboard then get your app key, secret key and access token.
Setup
To use Dropbox, first install the unofficial PHP SDK kunalvarma05/dropbox-php-sdk
:
composer require kunalvarma05/dropbox-php-sdk:^0.4
Create Dropbox App
Login to Dropbox and go to the developer page:
Create a new app:
- Selecting the "Scoped access" API
- Choose "App Folder" for the type of access you need.
- Name your app (this needs to be unique to Dropbox, so something like "Acme Ltd. Craft Remote Backup")
On the next page (the "settings" tab) first note down your "App Key" and "App Secret":
Then scroll down to the "Oauth2" section and generate a new access token:
This allows us to access the app without having to go through the OAuth flow.
Finally, go to the "Permissions" tab and enable:
files.metadata.write
files.metadata.read
files.content.write
files.content.write
Configure Remote Backup
Configure Remote Backup to use the new Access Token. The best way to do this is to create a .env
in your project and add the following variables:
DROPBOX_APP_KEY="..."
DROPBOX_APP_SECRET="..."
DROPBOX_ACCESS_TOKEN="..."
Then reference these in the Remote Backup settings page:
Folder Setting
Dropbox will automatically create a folder within the "Apps" folder with the name of your app:
If you leave the "Dropbox Folder" setting in Remote Backup empty, your backups will be placed directly into this folder.
You can optionally choose a subfolder within this folder via "Dropbox Folder" setting. If using the setting, make sure your path begins with a slash but doesn't end with a slash.
For example, these are correct:
/put-my-backups/in-here
/Craft Backups
/My New Project/Backups
But these will cause errors:
My New Project/Backups
/files/my-backups/
files/by-backups/
Bear in mind, this folder must already exists as Remote Backup will not create it for you (you'll get an error).
Notes
A few notes:
- There is an OAuth flow available for authentication but we avoid that in favour of the access token approach.
- We are using "App Folder" permission type which means Craft Remote Backup only ever has access to its own folder, not your Dropbox at-large. Remote Backup might work with full access, but it's not been tested
Troubleshooting
If you are encountering errors, first check your credentials. After that, have a look in storage/logs/web.log
for errors. Usually these issues are related to credentials or folder paths. If you're still having trouble, see the troubleshooting section.
409 Conflict
If you see an error like the following in your logs:
Client error:
POST https://api.dropboxapi.com/2/files/list_folder
resulted in a409 Conflict
response: {"error_summary": "path/not_found/", "error": {".tag": "path", "path": {".tag": "not_found"}}}
You need to make sure that the folder you listed in the "Dropbox Folder" setting already exists.