Pat Pawlowski

PHP Script to download Sugar backups from the pbs_Backups module

Discussion created by Pat Pawlowski on Jun 26, 2017
Latest reply on Jun 29, 2017 by Pat Pawlowski

I don't know about everyone else but when I need to download a Sugar backup it's usually to a headless Linux machine and not to a machine with a UI and a browser. I created this script for just that.

You can download the gist from here or just run

curl https://gist.github.com/patpawlowski/486ea6d6b84bb6b7e90c5474ae5f001c/raw/ce08c191c8b3656d8749ef15c446b706a786b02b/sugarbackupdownload.php > sugarbackupdownload

Make it executable:

chmod +xxx sugarbackupdownload 

And then run it:

php sugarbackupdownload
Enter base URL. ex: https://mysugar.sugarondemand.com:> https://mysugar.sugarondemand.com
Enter username:> Ticomix
Enter password:> SomePassword

Connecting to Sugar and getting list of backups . . . 

0 mysugar.sugarondemand.com - 7821ent 2017-06-26T00:26:33+00:00
1 mysugar.sugarondemand.com - 7820ent 2017-05-02T20:50:31+00:00

Enter the number of the backup to download:> 0

Connecting to xxxxxxxxxx|:443... connected.

HTTP request sent, awaiting response... 200 OK
Length: 59485709 (57M) [binary/octet-stream]
Saving to: `mysugar.sugarondemand.com.7821ent.1498436798.ca3984af5135c32c706fd36cf6e47ba0cae7c840.tar.gz'

100%[====================================================================================================================>] 59,485,709 18.6M/s in 3.0s

2017-06-26 10:02:54 (18.6 MB/s) - `mysugar.sugarondemand.com.7821ent.1498436798.ca3984af5135c32c706fd36cf6e47ba0cae7c840.tar.gz' saved [59485709/59485709]

 

And that's all there is to it. You should now have the backup sitting wherever it was you ran the script. 

 

If anyone has a better way to do this or any way to enhance this script please speak up. Maybe I missed something very simple like curl or wget but I think the oauth login prevents just using those alone. 

 

-pat

Outcomes