And well since we already keep everything backed up, it wasn’t much of a big deal to spawn a new instance and get back online. Also with that, Markitty had its first down time since the launch.
But it taught me a lesson that we couldn’t really trust AWS infrastructure with our customers data.
So, I hacked this
python script that would take a regular backup of our main database and upload it to one of our Dropbox folders.
It includes 3 main files:
db_backup.sh is the shell script that makes use of pg_dump to get the compressed backup of the database.
uploader.py is the Python script that uploads the database to the Dropbox folder.
client_secrets.json stores the credentials including
You need to provide the
Follow these steps to setup the Dropbox app:
You will need to create a Dropbox app, to get the Appkey and AppSecret. You can create it here (select the App Type as
Coreand select the Permission type as
Once the app is successfully created, Dropbox will provide you the
app_secret. Provide this
client_secrets.json(please do not share your
Then execute the uploader.py, it will generate an authentication link which you will need to open in your web browser. Press the Allow button, and hit Enter in the shell.
It will then print the
access_secret, that you will need to provide in the
client_secrets.jsonAnd you are done with the Dropbox setup.
After that, you can setup a Cron job that will execute the db_backup.sh everyday and get your Database backup in your Dropbox folder. The scripts all yours under Creative Commons License :-)
You can fork it on Github here.