Giter VIP home page Giter VIP logo

mysql-ssh-backups's Introduction

MySQL backups with Python & SSH

Description

Backup the MySQL databases of all your hosted websites to your computer by using an SSH connection to the webserver.

How to use it

  1. Make sure you have pip & python installed

  2. Install the paramiko package sudo pip install paramiko

  3. Download or git clone the source files

  4. Make sure that you can access your webserver by using SSH. You’ll need to make an SSH key.

  5. Copy the result of cat ~/.ssh/id_rsa.pub

  6. SSH to your server

  7. vim ~/.ssh/authorized_keys

  8. Paste the contents (your key) and save

  9. ctrl+d to exit

  10. Open the config/config.json.dist and rename it to config/config.json and fill the details of your webserver and database credentials. You can add as many webservers/databases as you want!

     {
         "settings": {
             "backup_folder": "backup/"          /* The local backup folder */
         },
         "websites": {
    
             "name_firstwebsite": {
                 "config": {
                     "host": "",                 /* Webserver hostname */
                     "username": ""              /* Webserver username */
                 },
                 "databases": {
                     "database_examplename1": {
                         "mysql_host": "",       /* Mysql hostname */
                         "mysql_user": "",       /* Mysql username */
                         "mysql_pwd": ""         /* Mysql password */
                     }
                 }
             },      
    
             "name_secondwebsite": {
                 ...
             }
         }
     }
    
  11. Run python backup-mysql-database-ssh.py to backup your database or configure it to run periodically as a cronjob (OS X tip: Lingon). Using Lingon, create a new task, give it a name and let it execute /usr/bin/python /Users/pathtoscript/backup-mysql-database-ssh.py at e.g. every 12 hours.

Bugs

If you encounter any bugs, please create an issue and I’ll try to fix it (or feel free to fix it yourself with a pull-request).

Discussion

mysql-ssh-backups's People

Contributors

jessedobbelaere avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

mysql-ssh-backups's Issues

SSH Keys

Hey, first of all great work, your script has got me over a hurdle I was stuck on.

One issue I encountered was regarding the Paramiko connect class. Your script has look_for_keys=False which prevented a connection being made (for me anyway).

Forgive me if I'm missing something (I'm a Python newbie!), but removing that argument made the script work perfectly.

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.