Connect Google Cloud SQL from Local Machine using Unix Socket

You need to install Google Cloud SDK and check if you have gcloud command available in terminal. After installing gcloud you need to configure gcloud sdk by running gcloud init command.

I am assuming, you have configured your Google Cloud SQL instance for your project. If yes, then continue, otherwise you need to read “Google Cloud SQL Quickstarter Guide“.

Now Download cloud_sql_proxy.linux.amd64 package in your local machine with

"sudo wget"

this command.

Rename by mv cloud_sql_proxy.linux.amd64 cloud_sql_proxy
and give execution permission by chmod +x cloud_sql_proxy

Create application default credentials using “gcloud auth application-default login” command

Create a directory sudo mkdir -p /cloudsql for Google Cloud SQL proxy unix socket and make that directory writable sudo chmod 777 /cloudsql

start sql socket proxy by ./cloud_sql_proxy -dir=/cloudsql &

At last,
Now you can have working mysql DSN “mysql:unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME” which you can use in your application and your application will work with Google Cloud SQL instance directly from local machine.

Please ask me anything about this post in comment below. I will be glad to assist you happily.


Syncing between Linux and Rackspace Cloud Files

Whole the night I was struggling to build a safe house for my codes where my codes can live longer safely. Sounds funny? Yes, it is. So whenever you or I think about to build a safe place to host our codes then first priority we consider about Backup and Restoring files with less hassle. And today I figured our a very sophisticated way about to handle synchronizing or backup/restore your files between your Linux flavor computer and Rackspace Cloud Files.

In my research case I had one cloud server on Rackspace. That server was powered by Ubuntu Server 14.04 LTS. I usually use Rackspace Cloud Files to keep my backup files on cloud so I can easily use them. So I wanted to figure our a very simple way to handle the backup which will automatically take backup and store those backups to Rackspace Cloud Files.

Suddenly for God’s sake I got a link in Rackspace forum that was about FileConveyor. OMG! This tools really works amazing. So I can easily upload backup from my cloud server to Rackspace Cloud Files with this life saving FileConveyor.

Here is the process to install FileConveyor in your server or personal Linux flavor computer.

  • First you have to install Git with sudo apt-get install git
  • You must have to install Python and Python Package Manager. To install python Package Manager you have to run this command wget -O - | sudo python.
  • After installing Pythin Package Manager you can use easy_install command. And now install pip with this easy_install command like sudo easy_install pip
  • Now choose where you want FileConveyor files by using cd command. And then run this sudo pip install -e git+ command. So you will get all the required python files for fileconveyor from GitHub.
  • Now it’s time to write your own config.xml files for this tools. Now need to create this config.xml file and write the following XML content inside that file with this command sudo vi src/fileconveyor/fileconveyor/config.xml with the following content.
  • <?xml version="1.0" encoding="UTF-8"?>
      <!-- Sources -->
      <sources ignoredDirs="">
        <source name="test" scanPath="/var/www/html/test" />
      <!-- Servers -->
        <server name="Rackspace Cloud Files" transporter="cloudfiles">
     <!-- Rules -->
        <rule for="test" label="Test">
            <destination server="Rackspace Cloud Files" path="test" />


You’ll need to modify the config to fit your environment and account details.

In the “Sources” section change the “scanPath” property to the directory you want to sync.
In the “Servers” section set “username” and “api_key” to match your credentials, and set “container” to the name of the container to hold the synced files.
In the “Rules” section set the “path” property to the subdirectory to sync to in the container. Leave the value blank to sync to the root of the container (path=””).

Now run this awesome tools with this sudo python src/fileconveyor/fileconveyor/ command.

Note: If you see any error like Transport class not found or something related to transport class then please install django-cumulus==1.0.10 package with this command pip install django-cumulus==1.0.10. Now again run FileConveyor and it will start syncing.

It’s cool! huh? Of course it will save you from losing life for codes.

To stop the fileconveyor process run this kill -TERM cat ~/ command