{"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 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 <\/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 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 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 , if you are not already<\/p>\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 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 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":"\nSetup Dropbox<\/h3>\n
Prepare the Server Environment<\/h3>\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`\/<\/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
Install the script<\/h3>\n
# escalate to root<\/code><\/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
Configure the transport in WHM<\/h3>\n
Get backing up!<\/h3>\n
\n