{"id":49085,"date":"2018-06-05T12:54:45","date_gmt":"2018-06-05T17:54:45","guid":{"rendered":"https:\/\/blog.cpanel.com\/?p=49085"},"modified":"2018-06-05T12:54:45","modified_gmt":"2018-06-05T17:54:45","slug":"cpanel-whm-custom-backup-transport-example-dropbox","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/","title":{"rendered":"cPanel & WHM Custom Backup Transport Example: Dropbox"},"content":{"rendered":"

The cPanel backup system provides lots of flexibility, and one of its awesome features is the ability to create\u00a0custom backup transports<\/a>. In cPanel, a backup transport or destination is a method to move backups to a secondary\/remote server for safe keeping. The custom backup transport feature allows you to specify a script which the backup system will pass arguments to; arguments common with uploading files in FTP, e.g. ‘put $filename’. Reading over the documentation, it may at first appear a daunting task; however, today we’ll walk you through the process by creating a backup destination utilizing\u00a0Dropbox and their very thoroughly documented\u00a0API<\/a>.<\/p>\n

Setup Dropbox<\/h3>\n

If you don’t already have a Dropbox account, create one\u00a0here<\/a>. Once you have an account, head over to their developer section to\u00a0create an app<\/a> (this is required to use their API). You’ll be prompted to select the typical\u00a0Dropbox API<\/em>\u00a0or the\u00a0Business\u00a0API<\/em>. For our testing purposes, we’ll stick with the free\u00a0Dropbox API<\/em>. For step two of the app creation process, select\u00a0Full Dropbox<\/em>. Finally, set a name for your app; I chose ‘cpanel-backups.’<\/p>\n

\"New<\/a><\/p>\n

After creating the Dropbox app, you’ll be redirected to the\u00a0Settings<\/em>\u00a0page for your\u00a0app, which will provide your API credentials. Keep track of the\u00a0App Key<\/em>, and\u00a0App Secret.<\/em>\u00a0Then click the\u00a0Generate access token<\/em>\u00a0button and retain that as well.<\/p>\n

<\/a><\/p>\n

Prepare the Server Environment<\/h3>\n

Now that we have everything we need from Dropbox to configure the custom transport, let’s prepare the server environment.\u00a0To make things simple, we’ll utilize CPAN\u00a0WebService::Dropbox<\/a>. On CentOS 7.4, this installed without complication. However, on CentOS 6,\u00a0 I also needed to install the\u00a0perl-YAML<\/em>\u00a0package.<\/p>\n


\n# CentOS 7
\nsudo cpan WebService::Dropbox
\n# CentOS 6
\nsudo yum -y install perl-YAML
\nsudo cpan WebService::Dropbox
\n<\/code><\/p>\n

Now that we have the CPAN module installed, take the time to briefly read over the\u00a0custom transport documentation<\/a> to familiarize yourself with the system. Once done, read over the template files we ship with cPanel, located in the following locations:<\/div>\n
\u00a0<\/div>\n
`\/<\/em>usr\/local\/<\/em>cpanel\/scripts\/custom_backup_destination.pl.sample<\/em>'<\/code><\/div>\n
<\/code>and<\/span><\/div>\n
`\/<\/em>usr\/local\/<\/em>cpanel\/scripts\/custom_backup_destination.pl.skeleton<\/em>'<\/code>.<\/span><\/div>\n
\u00a0<\/div>\n
Keep in mind that since we ship both the sample and skeleton files, direct edits to these files will be overwritten during nightly updates! Be sure you do not use the same file path as these templates. During the CPAN installation for WebService::Dropbox, you may be prompted to answer “Do you want to install it permanently?<\/em>”\u00a0 Since these are relatively small modules and having them installed will help with future CPAN module installations, so I chose “yes<\/strong>” for each prompt.<\/div>\n

Install the script<\/h3>\n

We understand that not everyone has the time to learn a new programming language, so we’ve done a lot of the heavy lifting for you by uploading our Dropbox custom backup transport script to\u00a0GitHub<\/a>. I highly encourage you to look at the script and see what can be done here with just over 100 lines of code. Clone and copy the script into place:<\/p>\n

# escalate to root<\/code><\/p>\n

, if you are not already<\/p>\n

sudo su - root
\n# clone and copy the script from github
\ncd \/usr\/local\/src<\/code><\/p>\n

\n<\/code><\/p>\n

cp -av backup-transport-dropbox\/backup_transport_dropbox.pl \/usr\/local\/bin\/<\/code><\/p>\n

With your favorite text editor, take the Dropbox credentials you saved earlier and update the\u00a0MY_APP_KEY<\/em>,\u00a0MY_APP_SECRET<\/em>, and\u00a0MY_ACCESS_TOKEN<\/em>\u00a0placeholders.<\/div>\n

Get backing up!<\/h3>\n

Congratulations, you’ve just created your first custom backup transport script, how cool is that?! Feel free to fork us on GitHub and be sure to share with us your custom backup transport scripts!<\/p>\n


\n

If you haven’t already, join us in our semi-official cPanel Discord<\/a>\u00a0or\u00a0Slack.<\/a><\/em><\/p>\n

\u00a0<\/p>\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

The cPanel backup system provides lots of flexibility, and one of its awesome features is the ability to create\u00a0custom backup transports. In cPanel, a backup transport or destination is a method to move backups to a secondary\/remote server for safe keeping. The custom backup transport feature allows you to specify a script which the backup […]<\/p>\n","protected":false},"author":77,"featured_media":64945,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[609,2033,2037],"class_list":["post-49085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-products","tag-backup","tag-custom-transport","tag-dropbox"],"acf":[],"yoast_head":"\ncPanel & WHM Custom Backup Transport Example: Dropbox | cPanel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"cPanel & WHM Custom Backup Transport Example: Dropbox | cPanel\" \/>\n<meta property=\"og:description\" content=\"The cPanel backup system provides lots of flexibility, and one of its awesome features is the ability to create\u00a0custom backup transports. In cPanel, a backup transport or destination is a method to move backups to a secondary\/remote server for safe keeping. The custom backup transport feature allows you to specify a script which the backup […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/\" \/>\n<meta property=\"og:site_name\" content=\"cPanel\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cpanel\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-05T17:54:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/devel.www.cpanel.net\/wp-content\/uploads\/2018\/06\/2018.06.05.backups.transport.png\" \/>\n\t<meta property=\"og:image:width\" content=\"3858\" \/>\n\t<meta property=\"og:image:height\" content=\"1527\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"cPanel Community\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cPanel\" \/>\n<meta name=\"twitter:site\" content=\"@cPanel\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cPanel Community\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/\",\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/\",\"name\":\"cPanel & WHM Custom Backup Transport Example: Dropbox | cPanel\",\"isPartOf\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\"},\"datePublished\":\"2018-06-05T17:54:45+00:00\",\"dateModified\":\"2018-06-05T17:54:45+00:00\",\"author\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\"},\"breadcrumb\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/devel.www.cpanel.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"cPanel & WHM Custom Backup Transport Example: Dropbox\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\",\"url\":\"https:\/\/devel.www.cpanel.net\/\",\"name\":\"cPanel\",\"description\":\"Hosting Platform of Choices\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/devel.www.cpanel.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\",\"name\":\"cPanel Community\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"caption\":\"cPanel Community\"},\"description\":\"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.\",\"sameAs\":[\"https:\/\/cpanel.net\"],\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"cPanel & WHM Custom Backup Transport Example: Dropbox | cPanel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/","og_locale":"en_US","og_type":"article","og_title":"cPanel & WHM Custom Backup Transport Example: Dropbox | cPanel","og_description":"The cPanel backup system provides lots of flexibility, and one of its awesome features is the ability to create\u00a0custom backup transports. In cPanel, a backup transport or destination is a method to move backups to a secondary\/remote server for safe keeping. The custom backup transport feature allows you to specify a script which the backup […]","og_url":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/","og_site_name":"cPanel","article_publisher":"https:\/\/www.facebook.com\/cpanel\/","article_published_time":"2018-06-05T17:54:45+00:00","og_image":[{"width":3858,"height":1527,"url":"https:\/\/devel.www.cpanel.net\/wp-content\/uploads\/2018\/06\/2018.06.05.backups.transport.png","type":"image\/png"}],"author":"cPanel Community","twitter_card":"summary_large_image","twitter_creator":"@cPanel","twitter_site":"@cPanel","twitter_misc":{"Written by":"cPanel Community","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/","url":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/","name":"cPanel & WHM Custom Backup Transport Example: Dropbox | cPanel","isPartOf":{"@id":"https:\/\/devel.www.cpanel.net\/#website"},"datePublished":"2018-06-05T17:54:45+00:00","dateModified":"2018-06-05T17:54:45+00:00","author":{"@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8"},"breadcrumb":{"@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel-whm-custom-backup-transport-example-dropbox\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devel.www.cpanel.net\/"},{"@type":"ListItem","position":2,"name":"cPanel & WHM Custom Backup Transport Example: Dropbox"}]},{"@type":"WebSite","@id":"https:\/\/devel.www.cpanel.net\/#website","url":"https:\/\/devel.www.cpanel.net\/","name":"cPanel","description":"Hosting Platform of Choices","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devel.www.cpanel.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8","name":"cPanel Community","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","caption":"cPanel Community"},"description":"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.","sameAs":["https:\/\/cpanel.net"],"url":"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/49085"}],"collection":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/comments?post=49085"}],"version-history":[{"count":0,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/49085\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/media\/64945"}],"wp:attachment":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/media?parent=49085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/categories?post=49085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/tags?post=49085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}

Configure the transport in WHM<\/h3>\n

We’re now ready to configure the transport in WHM. Head over to WHM\u00a0\u00bb Backup \u00bb Backup Configuration and scroll down to\u00a0Additional Destinations<\/em>. Under\u00a0Destination Type<\/em>, select\u00a0Custom<\/em>, then\u00a0Create new destination<\/em>. Configure the destination as below (note, since we’re using the API keys directly in the transport script, you can enter anything for the host, user, and password):<\/p>\n

<\/a><\/p>\n

Be sure to hit\u00a0Save and Validate Destination<\/em>\u00a0at the bottom of the screen.<\/p>\n