Skip to main content

Dropbox Backup Extension

Introduction

From my own experience of VPS usage, I noticed the need for cloud backup storage. The current version of Backup Manager for Parallels Plesk Panel does not support any remote storage except FTP, but I wanted to utilize a cloud storage for that purpose.

As a developer, I wanted to implement a complete solution for the problem and share it with the Plesk community. Starting from version 11.0.9, you can add new functionality to Plesk with extensions – this is exactly what I needed.

For my experiment, I chose Dropbox as a place for my stuff. It has a rather simple REST API with a lot of implementations for different programming languages. I used PHP SDK by Ben, but now the official Dropbox SDK is available.

Backend

In order not to reinvent the wheel, I decided to use native backup and restore utilities in Plesk:

The Dropbox Backup extension that I created executes command line scripts on behalf of the psaadm user. Unfortunately psaadm does not have the permission to restore a backup for security reasons. The utilities have to be executed as root. Moreover, backend operations are rather heavy and take a lot of time for execution. They should be executed asynchronously.

In order to resolve these issues, I implemented a task manager: a scheduled script in cron that is run every minute with root privileges:

The script of the task manager is not run, if a previous operation has not been completed yet. To achieve this, I used a locking technique, which is based on flock system call, so there will be no blocked or waiting processes of the task manager.

Tasks are stored in a SQLite database, so we can track tasks statuses in the UI and pass arguments to the backend script.

The utilities execution is very simple:

The $output and $code variables are written by corresponding output and return the utility status. In order to have stderr dump, the 2>&1 redirect should be used.

 

User Interface

The major goal of the Dropbox Backup extension is to back up a Plesk subscription. Thus, the extension entry point should be placed on the Websites & Domains screen in Plesk.

The post-installation script should create a custom button using API-RPC gateway:

 

Let’s see the result:

dropbox-custom-button

 

Dropbox uses the OAuth protocol for authorization. The first handling of an API call will redirect you to your Dropbox account in order to get a token for the Dropbox Backup extension:

dropbox-authorize

 

The extension gets tokens for each Plesk subscription – different subscriptions may use different accounts. The tokens are encrypted and stored in the SQLite database. When a Dropbox account is successfully authorized, the /Apps/plesk-backup/ folder is created in this account. Your backup files will be stored in this folder.

The general screen of the Dropbox Backup extension shows the list of available backups. You can extend the pm_View_List_Simple class to view your own data, paging, sorting controls and other tools in this list.

dropbox-repository

 

To back up files for the current subscription immediately, click the ‘Back Up Now’ button. All backup and restoration tasks are shown on the ‘Current Tasks’ tab:

dropbox-current-tasks

 

The ‘Settings’ tab allows you to set up scheduled backups. Its implementation extends the pm_Form_Simple class and consists of the basic elements: a checkbox and a text input area.

dropbox-settings

 

A backup file is named after the subscription and uploaded to Dropbox. So, in case a previous backup file already exists, it will be overwritten. But Dropbox keeps changes for 30 days. There is no need to rotate the filename, because previous files are still available.

If you are going to restore the subscription (I hope you won’t), click on the backup name and choose the version of the backup file:

dropbox-restore

 

There is a small pleasant thing: Dropbox client notifies you about any file update:

dropbox-notification-mac

 

Resume

The following features are available in the implemented extension:

  • Immediate backup of a subscription.
  • Scheduled (daily) backup of a subscription.
  • Restoration of a subscription backup (choose one of 10 previous versions).
  • Files are rotated by Dropbox: your storage will never be full.

There are some known problems and limitations:

  • Only Linux OS is supported by now.
  • Backup/restoration of the server/customer/reseller is not implemented.
  • Unable to restore a backup on a server different from the one where it was created.

As a VPS owner, I have the desired solution for cloud backup storage. I spent several days developing and the result was worth it.

The extension is free and can be downloaded here.

You can ask any questions related to the extension and give your feedback in the thread on our official forum.

42 thoughts

  1. Powie -

    Thanks for this great extension.
    Maybee I can help for localization

    Reply

    Eugene Kazakov -

    Thank you for the proposal.
    Unfortunately, localization is not available now, we will introduce it in next version.

    Reply

  2. Luis -

    I Installed it and always said me Failed.

    Reply

    Eugene Kazakov -

    Open Plesk Backup Manager, it should has notification about failures with link to the log file.
    Also you can check /usr/local/psa/var/modules/dropbox-backup/debug.log

    Reply

  3. Markus Eyrich -

    Nice one, but i personally would like to see the same with Google Drive, since i don’t use Dropbox at all.

    Reply

  4. Kevin -

    I’ve tried installing this several times, but it doesn’t work. It just reloads the same page as whatever you are on. No errors in logs.

    Reply

  5. Aarat -

    I am getting

    Failed to Execute: /usr/local/psa/bin/pleskbackup domains-id –output-file=/usr/local/psa/var/modules/dropbox-backup/filename.tar 4 2>&1 Output: Runtime error: Unknown error from pmmcli

    Reply

    Eugene Kazakov -

    This is not a problem of the extension, something wrong with backup in panel – does it work in backup manager?
    See /usr/local/psa/PMM/logs/pmmcli.log for detailed error messages.

    Reply

  6. Croveh -

    ONLY Dropbox ? Dropbox offers only 2 GB free while Google Drive gives me 25 GB FREE and the same goes for Microsoft OneDrive. Not to mention i have 50 GB FREE from Box.com.

    Also another problem with Plesk backup is the lack of options, i need to backup DAILY only the DATABASE of a client and store it in a cloud not the entire site because the site files do not change every day

    Reply

  7. Alonso -

    Hello,

    I’m trying to install the extension but I get this error:

    Error: No se pudo instalar la extensión: Executing /usr/local/psa/admin/plib/modules/dropbox-backup/scripts/post-install.php failed: ERROR: PleskUtilException: /usr/bin/crontab execution failed: “crontab9Cks7x”:20: bad command errors in crontab file, can’t install. System error: crontab execution error (Agent.php:212)

    Can I you can help?

    thanks

    Reply

    Eugene Kazakov -

    Hello,
    It looks very strange. Can you specify your OS?

    Lets try to debug crontab commands. Run in console:
    while :; do [ -f /usr/local/psa/tmp/crontab* ] && cat /usr/local/psa/tmp/crontab* && break; done

    Now install the extension. You should see output in console:
    MAILTO=””
    * * * * * /usr/local/psa/admin/bin/php -c ‘/usr/local/psa/admin/conf/php.ini’ -dauto_prepend_file=sdk.php ‘/usr/local/psa/admin/plib/modules/dropbox-backup/scripts/plesk-task-manager.php’

    Reply

  8. Scott -

    Hi
    I was directed here from the support forum so apologies if this in the wrong place.

    I am using Plesk Panel 12.0.18 MU4 and I know that I can back up individual subscriptions to Dropbox but am I correct in thinking that it is not possible to do full server back up this way? (At the moment I have the server backing up to my FTP server but would like it to go to Dropbox)

    If it is possible can tell me how? If it isn’t, I am interested to know if there is a specific reason the main server backup system does not have this facility when it seems to be fairly trivial (at least on the face of it) to port this function to there as well as to the individual subscriptions?

    Reply

    Eugene Kazakov -

    Hi, Scott.
    Yes, you’re right. Server backup is not available in the current version of the extension.
    Thanks for your request, we’ll think on implementing this missing functionality.

    Reply

  9. Tom -

    Hi Eugene,

    I asked my host to install the plugin on our VPS (Plesk 11.5). The Dropbox icon is visible in each subscription but doesn’t connect to Dropbox upon clicking, We only get a empty Plesk window. Might this due to an flawed or incomplete installation? Any hints would be appreciated.

    Reply

    Eugene Kazakov -

    Hi Tom,

    Could you provide more details?
    Tell me the URL of empty window.
    Also check /usr/local/psa/admin/logs/panel.log for some errors.

    Recently the problem with Dropbox authorization was reported due to restricted access inside frames. It is reproduced in case enabled ‘Open hosting operations in Server Administration Panel’ in ‘Interface Management’. I’d recommend to use ‘Power User view’ (it has no frames). We will try to workaround this known problem.

    Reply

  10. Tom -

    Hi Eugene,

    yes you were right, with power user view the problem got solved but now we encountered another one while trying to do a restore. The restore failed with the following message:

    >>Failed to Execute: /usr/local/psa/bin/pleskrestore –restore /usr/local/psa/var/modules/dropbox-backup/cortaespuma.es.tar -level domains -filter list:cortaespuma.es 2>&1 Output: Unable to resolve all conflicts<<

    Any suggestion of how to get round this one?

    Reply

    Eugene Kazakov -

    Your backup has some conflicts, there is no ability to resolve it via extension.
    I’d recommend to upgrade extension to 2.0 version: it allows to import backup to local repository (or you can do it manually). After that use Plesk Backup Manager to resolve conflicts and restore the backup.

    Reply

    Adam Cooley -

    I’m also seeing this error, just a blank page. Is there a fix we can incorporate instead of using the power use view?

    Reply

    Eugene Kazakov -

    You can workaround the issue: open the extension in a new browser tab, authorize in Dropbox, and then use it as usual.

    Reply

  11. Misha -

    Hi Eugene,

    Thank You for your work! On thing I can’t find. Your extension make backup of all server including database or without database?

    Best regards.

    Reply

    Eugene Kazakov -

    Hi Misha,

    The extension backups all databases associated with subscriptions in Plesk.

    Reply

  12. Lynn Kasdorf -

    Thanks for creating this extension. It is very handy and works great. But… I am on a 1and1 dedicated server. The /usr partition is only allocated 4.2 GB and since I have started using the dropbox extension, I have had the /usr partition disk usage got to 100%, and then the server is effectively down.

    The last time this happened, I tracked it down to a large tar file that was a backup of one of the domains. I don’t recall the exact path, but it was in the /usr partition.

    I assume that this extension creates the backup archive in a temp folder inside /usr and then sends it to dropbox, and then deletes the temp archive. In this case, it ran out of room.

    I wonder if it would be simple to modify where the temp files are created? Like somewhere in /var or /home?

    Thanks for any ideas on this. I have had to turn of the dropbox backups until I get this figured out.

    Reply

    Eugene Kazakov -

    Maybe the symlink helps you?
    # mv /usr/local/psa/var/modules/dropbox-backup /var/
    # ln -s /var/dropbox-backup /usr/local/psa/var/modules/dropbox-backup

    Reply

    Lynn Kasdorf -

    Eugene- thanks for the idea. It almost worked.
    I did as you suggested, and ran a backup, while monitoring the folder /var/dropbox-backup.

    Sure enough, after a while I saw the temp backup file appear there and watched as it got larger, eventually exceeding 5GB. I kept running df -h and observed that the /var partition disk usage slowly climbed, and NOT the /usr partition. So, this all looked perfect.

    Then, when it completed, in the current tasks tab of dropbox backup, the backup event showed “Failed” with this message: “Failed to Execute: ‘/usr/local/psa/bin/pleskbackup’ domains-id –output-file=’/usr/local/psa/var/modules/dropbox-backup/serara.org.tar’ 10 2>&1 Output: Runtime error: The backup failed with errors! ”

    Any ideas? Would it be possible for me to modify the code to just point to a /var folder directly rather? Maybe this is a permissions issue? I have no idea.

    Thanks-

    Reply

    Eugene Kazakov -

    The errors you got seems not to be in the extension, but in Plesk Backup Manager. Open it in Panel (Websites&Domains > Backup Manager) and check the detailed information about errors.

    Reply

  13. Paul Thompson -

    I’ve managed to get the extension working successfully for individual domains and yesterday tried a server backup. It failed with the message ‘internal server error’.

    Looking at /usr/local/psa/var/modules/dropbox-backup/debug.log,I can see that the tar file was created and then the step ‘Dropbox Upload:’ started. After 15 minutes (exactly), Internal Server Error is reported in this file and that’s it.

    Do you have any ideas why this might happen?

    Thanks.

    Reply

    col -

    this is happening with me too. the first backup i did worked ok (900MB tar file uploaded). i tried another back up and it failed. i thought maybe because it was a duplicate filename problem so i renamed the first dropbox tar and tried again.
    same thing happened.
    tried it a third time and it worked. hadn’t changed anything.

    Reply

  14. Marcos Paulino -

    Got this working on Plesk 12. Some issues. One that I think is major.

    Resellers have access to the entire dropbox folder when they click on the dropbox icon. Any way to VERY quickly fix this?

    Clicking on Server Repository returns a white screen

    LMK Asap.

    Thanks!

    Reply

  15. Ronald -

    I wish BOX was supported because i have 50gb there 🙂

    Reply

  16. TeknoMobil -

    Hi
    Yandex Disk, cloud.mail.ru, box, google drive ?
    Dropbox 2gb

    Reply

  17. Gicu -

    Hello,

    I’ve got one backup file on dropbox saved.
    After reinstall my whole server Dropbox backup won’t let me restore choosen backup because is done on other Plesk panel and I have to -ignore-sign option but I don’t see that in Dropbox backup settings.

    So it is a second way to restore my whole system with this .tar file?

    I’m just downloaded my backup from dropbox and uploaded this to:
    /var/lib/psa/dumps/

    But Plesk don’t see this file… 🙁

    Reply

    Eugene Kazakov -

    Hello,

    Try to upload dump in Tools & Settings > Backup Manager.
    Also you can try to ignore-sign server-wide by adding in /usr/local/psa/admin/conf/panel.ini
    [pmm]
    allowRestoreModifiedDumps = true

    Reply

  18. Justin -

    I’m getting the following error whenever I try to restore any of my dropbox backups via the panel.

    Failed to Execute: ‘/usr/local/psa/bin/pleskrestore’ –restore ‘/usr/local/psa/var/modules/dropbox-backup/server.maninico.com.tar’ -level server 2>&1 Output: The backup file was extracted to “/var/lib/psa/dumps”. Unable to decrypt the backup: The specified key is not suitable.

    Can you please tell me where to specify the key or turn off the key?

    Many thanks.

    Reply

  19. Matt C -

    Love this extension – I also wish it could only do restore / show repository for domains that match the current site’s domain so that you can’t see other server backups.

    Also wish it has the option for the ‘split’ parameter in backup – my server backups are too big and aren’t sent over to dropbox

    Reply

  20. rb -

    Hi,
    I made a 10gb backup of a domain to Dropbox in Server A. But when I tried to restore it in Server B, I get the message that it failed.
    Can the restore be done only in the same server? Thanks!

    Reply

  21. ILKSIN DAGCAN TARAKCI -

    I dont have this extension installed but i am continuously getting below mail as failed cron…

    “Could not open input file: /usr/local/psa/admin/plib/modules/dropbox-backup/scripts/plesk-task-manager.php”

    Reply

    Eugene Kazakov -

    Take a look at the scheduled tasks of the user root – there might be tasks related to this extension, you can remove it and will no longer receive annoying mails.

    Reply

  22. Betty -

    I strongly recommend Backup & Restore Dropbox plugin on wordpress , its the best backup plugin I have seen in recent times. It allows for Unlimited dropbox backups, Unlimited dropbox restores, Unlimited local backups and Unlimited local restores. https://wordpress.org/plugins/dropbox-backup/

    Reply

  23. Kayvan Farzin -

    is there any way to make incremental back ups?
    the way i see it, this extension only does full back up if i run it daily and this will take so long depending on size of server and subscriptions to bac up.

    are you planning to use the plesk incremental back up function and include it to your dropbox extension???

    Reply

  24. Ben -

    Dear all,

    I use this wonderful extension for multiple domains but for a misterious reason, for 20 days now, all domains stopped to work. Task were scheduled but never ran.
    I uninstalled the module and re-installed it. Reconfigured the scheduling for each domain and most of my domains are now backed-up again.
    But, some domains are still not backed-up. Do you know what could cause this? Task are scheduled but stay in ‘planned’ state and never dissspears. I checked and the cron task is correctly set in the crontab of root user.

    Thank you very much for your help.

    Also, any chance to publish the sources of this module to github?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Shares
Tweet
Share
Share
Buffer
Reddit
+1