django-db-snapshot¶
Reusable Django app for fully automatic database snapshots
Contents¶
Installation¶
- Install backup server with LVM support. Install and configure
mylvmbackup
config file
$ apt-get install mylvmbackup
$ cp /etc/mylvmbackup.conf{,.bak}
$ cat > /etc/mylvmbackup.conf << END
[mysql]
user=root
password=123password123
socket=/var/run/mysqld/mysqld.sock
[lvm]
vgname=vg0
lvname=mysql
lvsize=2G
END
- Install
dbsnapshot
using pip:
$ pip install django-db-snapshot
- Add the
dbsnapshot
application toINSTALLED_APPS
- Configure django-celery on project settings
$ apt-get install redis-server
$ pip install django-celery
INSTALLED_APPS += ('djcelery',)
BROKER_URL = 'redis://127.0.0.1:6379/1'
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
import djcelery
djcelery.setup_loader()
- Sync database (
./manage.py syncdb
or./manage.py migrate
) - Run internal dbsnapshot server (
./manage.py run_dbsnapshot_server
) - Restart Redis instance
$ /etc/init.d/redis-server restart
- Add backup server and configure backup options on django admin interface (
/admin/dbsnapshot/server/
) - That’s all. Enjoy.
Settings¶
dbsnapshot
has some configuration:
DBS_SERVER_HOST = '127.0.0.1'
DBS_SERVER_PORT = 61216
DBS_BACKUP_DIR = '/var/cache/mylvmbackup/backup'
DBS_MLB_BIN = '/usr/bin/mylvmbackup'
Installation for development¶
$ sudo apt-get install virtualenvwrapper
$ mkvirtualenv django-db-snapshot
$ git clone https://github.com/LPgenerator/django-db-snapshot.git
$ cd django-db-snapshot
$ python setup.py develop
$ cd demo
$ pip install -r requirements.txt
$ python manage.py syncdb
$ python manage.py migrate
$ python manage.py shell
>>> import dbsnapshot
>>> print dbsnapshot.get_version()
Contributing¶
If you wish to contribute, please add corresponding tests.
Running tests:
make test
Checking coverage (requires coverage
package):
make coverage
Run tests for all python-django combinations
tox
Credits¶
Development Lead¶
- GoTLiuM InSPiRiT <gotlium@gmail.com>
Contributors¶
None yet. Why not be the first?
Contributing¶
You can grab latest code on master
branch at Github.
Feel free to submit issues, pull requests are also welcome.
Good contributions follow simple guidelines