Skip to main content

Download from Google Drive direct from cPanel server

I store cPanel backups on Google Drive and needed to restore a backup of a website which was 9GB.

Instead of downloading the file to my computer and re-uploading it to the server (which could take a considerable amount of time), I wanted to download the file straight from Google Drive to the server, this will download faster due to the connection of the server.

Unfortunately, a standard WGET does not work.

To do this, I went into Terminal for my cPanel server and downloaded pip:

sudo yum install python3-pip

To make sure python is installed, do pip3 –version

I then installed something called “gdown” which is a python extension to download from Google Drive.

pip3 install gdown

Once “gdown” is installed, you can download the Google Drive file by doing this:

gdown –id [ID OF GOOGLE DRIVE FILE] (See details below about setting the file for downloading on Google Drive)

The file should download into the folder you ran the script in. Typically you would run the script in the folder of the actual cPanel user.

When the file is downloaded, it may have permissions issues so in Terminal, you need to change the ownership to the username.

sudo chown -R [cpanelusername] :[cpanelusername] [FILENAME]

You should then be able to work with the file in File Manager in cPanel.

Note: Make sure when you unzip the file in cPanel that the account itself has enough space otherwise it fully extract to the folder and you will have missing files

Setting up the file to be publicly downloadable

Note: You must set the Google Drive file to be publicly accessible

Once you have set the link to be public, copy the link and open it in your browser and copy the ID of the Google Drive file. This is the ID you will use in “gdown”.

Leave a Reply