Coder Social home page Coder Social logo

dzonder / django-backup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andybak/django-backup-old

0.0 2.0 0.0 141 KB

Django management command to handle db and media backups. This fork has a lot of changes. See the README for info

Home Page: http://code.google.com/p/django-backup/

Python 100.00%

django-backup's Introduction

django-backup

http://github.com/andybak/django-backup

Backup, compress and restore database and media files. Transfer them via email or FTP and maintain a set number of dated versions on remote FTP server.

Requirements

My fork of Pysftp: https://github.com/andybak/Pysftp (a nice friendly wrapper around Paramiko: https://github.com/paramiko/paramiko)

Authors

New Features in this fork

  • Facility to backup media directories in addition to backing up SQL dump
  • Transfer backups to remote FTP site
  • cleanmedia and cleandb options allow you to only retain a set number of backups on the remote ftp site. Can specify via settings different values for days, weeks and years to retain (see below)
  • 'manage.py restore' pulls down the latest backup from FTP and feeds it to mysql
  • option to delete alllocal backups
  • if using FTP you can opt not to retain local copy of backups
  • Unfortunately Postgres support hasn't been kept up to date in this version. It shouldn't be that hard to replace.

Supported options for manage.py backup

::

--email default=None Sends email with attached dump file

--compress -c default=False Compress SQL dump file

--ftp -f default=False Store backup on remote FTP server

--media -m default=False Backup media dirs as well as SQL dump

--rsync -r default=False Backup media dirs with rsync

--nolocal default=False Keep local copies of backup

--deletelocal default=False Delete all local backups

--cleandb default=False Clean up surplus database backups

--cleanmedia default=False Clean up surplus media backups

--cleanlocaldb default=False Clean up surplus local database backups

--cleanlocalmedia default=False Clean up surplus local media backups

--cleanremotedb default=False Clean up surplus remote database backups

--cleanremotemedia default=False Clean up surplus remote media backups

--cleanrsync default=False Clean up broken rsync backups

--cleanlocalrsync default=False Clean up local broken rsync backups

--cleanremotersync default=False Clean up remote broken rsync backups

When rsync flag is combined with ftp flag data will be backed up using rsync to a remote server. When rsync flag is used without the ftp flag data will be backed up to the local machine.

Extra Settings

::

BACKUP_SQLDUMP_PATH = '/path/to/mysqldump' # mysqldump binary location BACKUP_LOCAL_DIRECTORY = '/path/to/backups' # Where to store local backups

BACKUP_FTP_SERVER = 'example.com' BACKUP_FTP_USERNAME = 'username' BACKUP_FTP_PASSWORD = 'password' BACKUP_FTP_DIRECTORY = '/path/to/backups/mysite' # If you store multiple backups on the same remote server ensure each one is in a different directory RESTORE_FROM_FTP_DIRECTORY = '/path/to/backups/mysite' # Where does the restore

# How many db backups should we keep on remote FTP? i.e. 1 per day for the last 7 days plus 1 per week for the last 4 weeks etc. BACKUP_DATABASE_COPIES = {

'daily': 7, 'weekly': 4, 'monthly': 12,

}

# Same as above BACKUP_MEDIA_COPIES = {

'daily': 1, 'weekly': 2, 'monthly': 4,

}

Note that the settings which include FTP in their name will also be used for rsync.

Examples

A db-only backup
python manage.py backup --ftp
db plus rsync media backup
python manage.py backup --media --rsync --ftp
db plus SFTP media backup
python manage.py backup --media --ftp
Restore the most recent backup including media
python manage.py restore --media
db plus rsync media backup, validate remote rsync backups, clearn surplus media and db backs, and do not keep local copies of backups.

python manage.py backup --media --rsync --ftp --deletelocal --cleanremotedb --cleanremotemedia --cleanremotersync

or

call_command("backup", ftp=True, media=True, delete_local=True, clean_remote_db=True, clean_remote_media=True, clean_remote_rsync=True)

django-backup's People

Contributors

andybak avatar artemrizhov avatar ashleyblackmore avatar dzonder avatar ellipsis753 avatar emperorcezar avatar fruitschen avatar mikexstudios avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.