GithubHelp home page GithubHelp logo

zaherg / database-backup Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 0.0 403 KB

This is just another database backup script

License: MIT License

PHP 100.00%
php symfony cli database backup backup-script composer backup-cli database-backup amazon-s3-storage

database-backup's Introduction

Database backup CLI app

PS: This work was inspired by many people around me, especially backmeup which was created by Arda Kılıçdağı.

The idea

I wanted to have a small cli app that I can use to backup my databases whenever I need and with simple modifications, so I tried bach/shell and I didn't like it.

So to make the story short this is what I have done so far, this is just a small backup cli app that you can use on your server and run it via cron jobs to create a backup for all your databases or for one of them if you pass it as a parameter.

Currently implemented backup drivers:

  1. Local backup.
  2. Dropbox.
  3. Amazon.

Installation

Requirement

Remember that you need to have composer installed locally, if its not installed locally you can get it from getcomposer.org

Via git clone

Right now the best way to install it is to clone the repository

git clone https://github.com/linuxjuggler/database-backup.git

then execute the following commands

cd database-backup
composer install

Via composer

You can install it using composer by executing the following command:

composer create-project damascene/database-backup

Via composer (globally)

You can install it using composer by executing the following command:

composer global require damascene/database-backup

PS: if you run it globally you can just use backup instead of ./bin/backup.

Using the phar file

We distribute a PHP Archive (PHAR) that has all dependencies (including the suggested) of database backup bundled in a single file. You can find the file under the assets of each release.

After downloading the file remember to run the following commands:

$ mv backup ./bin/backup
$ chmod u+x backup

Usage

  • You should create the configuration file using the command:
./bin/backup init

You will be asked for few questions which the app is going to use them later.

  • You can start the backup process using the command:
./bin/backup db:run --database my_database_name

if you didn't pass the database parameter it will backup all the databases.

  • you can list all the backup files that you have using the command:
./bin/backup db:list

Upgrade

Based on how you have install it you can run one of the following commands:

  • If installed via git:

from within your code directory run:

git pull origin master
  • If installed via composer:

from within your code directory run:

composer update
  • If installed via composer globally:
composer global update
  • Finally check the file config.yml.example for the new updates if you don't want to use the init command.

TODO

  1. Add Tests

database-backup's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar zaherg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

database-backup's Issues

Suggestion: add time to file name

Hello!
I've modified the version I'm running so the resulting file name has the time of the backup next to the database name. This is because if you run the command more than once per day (eg: hourly backup) you will not overwrite the previous one.

Great tool, thank you!

Cannot run via cron

Hello! Thanks for the tool!
It works wonders when I run the backup command from the terminal itself, but when adding it to my crontab I get errors, different depending on the command I use:

* * * * * cd /OBSCURED/database-backup/ && sudo ./bin/backup db:run

Logs the following:

`[INFO] The process will start now.

In Process.php line 985:

TTY mode requires /dev/tty to be read/writable.

db:run [-d|--database [DATABASE]]`

If I run simply:

* * * * * /OBSCURED/database-backup/bin/backup db:run

It claims that the init command must be run first. However, the config file exists.

I've tried different combinations of chmod and chown to the project, directories, files, etc, but nothing seems to work.
Any idea what might be going on?

Thank you!

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.