django-green-grove 0.1.2

Creator: danarutscher

Last updated:

Add to Cart

Description:

djangogreengrove 0.1.2

Collection of helpers to back up Django projects that use a Postgres database and a S3 bucket as media storage.

Quickstart
Install django-green-grove using pip:
pip install django-green-grove
Add the following to your settings.py module:
BACKUP_BUCKET_AWS_ACCESS_KEY_ID = ''
BACKUP_BUCKET_AWS_SECRET_ACCESS_KEY = '
BACKUP_BUCKET_BUCKET_NAME = ''
BACKUP_BUCKET_LOCATION = ''


Backup Project
We suggest to use this management command as a cron tab:
python manage.py backup_project


Tutorial
This tutorial covers the steps that are needed to backup and restore a Django project that uses a Dokku hosting with a Postgres database and a S3 Bucket as media storage.
Backup project

Connect to your server
Connect to the docker container: dokku enter <project_name>
python manage.py backup_project

Restore from backup

Connect to your server
Connect to the database: dokku postgres:connect db
Drop the database: DROP DATABASE <db_name>;
Recreate the database: CREATE DATABASE <db_name>;
Grant privileges: GRANT ALL PRIVILEGES ON DATABASE <db_name> to <username>;
Exit the postgres console and the session on the server
Download the database dump file from the bucket to your local machine: s3cmd cp <path_of_dump_file> .
Move the dump file to the server: scp <path_of_dump_file> <server>
Connect to your server
Import the dump: cat <file_name> | sudo docker exec -i dokku.postgres.db psql -U <username> <db_name>
Remove the media folder of your bucket (s3cmd or web interface)
Open up the terminal on your local machine
Copy the backup of the media folder back to the bucket:
s3cmd cp --recursive --acl-public s3://backups/<project_name>/<timestamp>/media/ s3://<project_name>/media/



Trivia
This package is named after the fictional retirement community where Tony Soprano, Paulie Gualtieri, and other Mafiosi admit their mothers, in The Sopranos.


Credits
Tools used in rendering this package:

Cookiecutter
cookiecutter-djangopackage



History

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.