Reusable Django app for fully automatic database snapshots
Project description
Django-Db-Snapshot
==================
What's that
-----------
Reusable Django app for fully automatic database snapshots.
We are using it for backup big databases (100GB+).
App can be run on several instances and managing from one place.
Installation
------------
1. Install backup server with LVM support. Install and configure ``mylvmbackup`` config file
.. code-block:: bash
$ 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
2. Install ``dbsnapshot`` using pip:
.. code-block:: bash
$ pip install django-db-snapshot
3. Add the ``dbsnapshot`` application to ``INSTALLED_APPS``
4. Configure django-celery on project settings
.. code-block:: bash
$ apt-get install redis-server
$ pip install django-celery
.. code-block:: python
INSTALLED_APPS += ('djcelery',)
BROKER_URL = 'redis://127.0.0.1:6379/1'
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
import djcelery
djcelery.setup_loader()
5. Sync database (``./manage.py syncdb`` or ``./manage.py migrate``)
6. Run internal dbsnapshot server (``./manage.py run_dbsnapshot_server``)
7. Restart Redis instance
.. code-block:: bash
$ /etc/init.d/redis-server restart
8. Add backup server and configure backup options on django admin interface (``/admin/dbsnapshot/server/``)
9. That's all. Enjoy.
Demo
----
.. code-block:: bash
$ apt-get install virtualenvwrapper redis-server
$ mkvirtualenv django-db-snapshot
$ git clone https://github.com/LPgenerator/django-db-snapshot
$ cd django-db-snapshot
$ python setup.py develop
$ cd demo
$ pip install -r requirements.txt
$ python manage.py syncdb
$ python manage.py migrate
$ redis-server >& /dev/null &
$ python manage.py runserver >& /dev/null &
$ xdg-open http://127.0.0.1:8000/admin/
Backup server configuration
---------------------------
.. code-block:: bash
$ sudo -i
$ cd /srv/
$ apt-get install python-mysqldb python-django python-pip supervisor
$ pip install django-db-snapshot
$ django-admin startproject dbback
$ cd dbback/
$ cat >> dbback/settings.py << END
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysql',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': 3306,
'TEST_COLLATION': 'utf8_general_ci',
}
}
INSTALLED_APPS += ('dbsnapshot',)
DBS_SERVER_HOST = '0.0.0.0'
DBS_SERVER_PORT = 61216
END
$ tail -12 dbback/settings.py
$ iptables -A INPUT -p tcp --dport 61216 -j ACCEPT
$ python manage.py run_dbsnapshot_server
$ cat > /etc/supervisor/conf.d/dbsnapshot.conf << END
[program:dbsnapshot_server]
command=/usr/bin/python /srv/dbback/manage.py run_dbsnapshot_server
user=root
numprocs=1
autostart=true
autorestart=true
stdout_logfile=/var/log/dbsnapshot.log
stderr_logfile=/var/log/dbsnapshot.err.log
startretries=25
END
$ /etc/init.d/supervisor restart
$ supervisorctl status
Screenshots
-----------
.. image:: /screenshots/server_change_list.jpg
.. image:: /screenshots/logs_chage_list.jpg
Compatibility:
-------------
* Python: 2.6, 2.7
* Django: 1.4.x, 1.5.x, 1.6.x
==================
What's that
-----------
Reusable Django app for fully automatic database snapshots.
We are using it for backup big databases (100GB+).
App can be run on several instances and managing from one place.
Installation
------------
1. Install backup server with LVM support. Install and configure ``mylvmbackup`` config file
.. code-block:: bash
$ 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
2. Install ``dbsnapshot`` using pip:
.. code-block:: bash
$ pip install django-db-snapshot
3. Add the ``dbsnapshot`` application to ``INSTALLED_APPS``
4. Configure django-celery on project settings
.. code-block:: bash
$ apt-get install redis-server
$ pip install django-celery
.. code-block:: python
INSTALLED_APPS += ('djcelery',)
BROKER_URL = 'redis://127.0.0.1:6379/1'
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
import djcelery
djcelery.setup_loader()
5. Sync database (``./manage.py syncdb`` or ``./manage.py migrate``)
6. Run internal dbsnapshot server (``./manage.py run_dbsnapshot_server``)
7. Restart Redis instance
.. code-block:: bash
$ /etc/init.d/redis-server restart
8. Add backup server and configure backup options on django admin interface (``/admin/dbsnapshot/server/``)
9. That's all. Enjoy.
Demo
----
.. code-block:: bash
$ apt-get install virtualenvwrapper redis-server
$ mkvirtualenv django-db-snapshot
$ git clone https://github.com/LPgenerator/django-db-snapshot
$ cd django-db-snapshot
$ python setup.py develop
$ cd demo
$ pip install -r requirements.txt
$ python manage.py syncdb
$ python manage.py migrate
$ redis-server >& /dev/null &
$ python manage.py runserver >& /dev/null &
$ xdg-open http://127.0.0.1:8000/admin/
Backup server configuration
---------------------------
.. code-block:: bash
$ sudo -i
$ cd /srv/
$ apt-get install python-mysqldb python-django python-pip supervisor
$ pip install django-db-snapshot
$ django-admin startproject dbback
$ cd dbback/
$ cat >> dbback/settings.py << END
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysql',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': 3306,
'TEST_COLLATION': 'utf8_general_ci',
}
}
INSTALLED_APPS += ('dbsnapshot',)
DBS_SERVER_HOST = '0.0.0.0'
DBS_SERVER_PORT = 61216
END
$ tail -12 dbback/settings.py
$ iptables -A INPUT -p tcp --dport 61216 -j ACCEPT
$ python manage.py run_dbsnapshot_server
$ cat > /etc/supervisor/conf.d/dbsnapshot.conf << END
[program:dbsnapshot_server]
command=/usr/bin/python /srv/dbback/manage.py run_dbsnapshot_server
user=root
numprocs=1
autostart=true
autorestart=true
stdout_logfile=/var/log/dbsnapshot.log
stderr_logfile=/var/log/dbsnapshot.err.log
startretries=25
END
$ /etc/init.d/supervisor restart
$ supervisorctl status
Screenshots
-----------
.. image:: /screenshots/server_change_list.jpg
.. image:: /screenshots/logs_chage_list.jpg
Compatibility:
-------------
* Python: 2.6, 2.7
* Django: 1.4.x, 1.5.x, 1.6.x
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-db-snapshot-1.0.b.tar.gz
(20.2 kB
view details)
Built Distribution
File details
Details for the file django-db-snapshot-1.0.b.tar.gz
.
File metadata
- Download URL: django-db-snapshot-1.0.b.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b4c4d642c933657de73022916d1d22af4364fc310b28ba5b81923bf40b199bb |
|
MD5 | e29529ebcc3d45f44e9a5e81c1d20d44 |
|
BLAKE2b-256 | c80c49b61f0f10c1710839570012a989a5dcdae4439c4ed94edfca59bc60ddcc |
File details
Details for the file django_db_snapshot-1.0.b-py2.py3-none-any.whl
.
File metadata
- Download URL: django_db_snapshot-1.0.b-py2.py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bb5f75bf9e8dae31fcde8afd7c71d261c48b1a81a996c45384e8d62570b7db3 |
|
MD5 | d88a557e7fc3a7a3a6fa4cc49783e68b |
|
BLAKE2b-256 | c7c3454c9f5a47467199a458ccdf070feefa24079024225bef6476e6c0de406e |