Skip to content

Instantly share code, notes, and snippets.

View lingxiaoyang's full-sized avatar

Ling X. Yang lingxiaoyang

View GitHub Profile
# Here's how to back up a named volume
# 1. Using a `ubuntu` image, we mount the named volume (`myproj_dbdata`) to a `/dbdata` folder inside the `ubuntu` container.
# 2. Then, we create a new folder inside the `ubuntu` container named `/backup`.
# 3. We then create an archive containing the contents of the `/dbdata` folder and we store it inside the `/backup` folder (inside the container).
# 4. We also mount the `/backup` folder from the container to the docker host (your local machine) in a folder named `/backups` inside the current directory.
docker run --rm -v myproj_dbdata:/dbdata -v $(pwd)/backups:/backup ubuntu tar cvf /backup/db_data_"$(date '+%y-%m-%d')".tar /dbdata
@ahankinson
ahankinson / generics.py
Created December 14, 2012 03:57
PATCH support for Django REST Framework. The Django Rest Framework (http://django-rest-framework.org/api-guide/serializers.html) does not provide support for the PATCH HTTP method. These two overridden classes will allow you to mix-in support for PATCH. Place these in your Django webapp and import them as needed. I've kept the same DRF file name…
from rest_framework import mixins
from rest_framework.generics import SingleObjectAPIView
from yourapp.mixins import PartialUpdateModelMixin
class RetrievePartialUpdateDestroyAPIView(PartialUpdateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
SingleObjectAPIView):