Coder Social home page Coder Social logo

database-dumper's Introduction

Publish PHPStan PHPCS-Fixer

Database Dumper

This tool automatically dumps your database(s) and either saves them to a specified directory or uploads them to a remote server. Currently SFTP and FTP are supported. See FilesystemFactoryInterface to implement new filesystem support (it uses league/flystem internally).

It also has a very simple and optional feature to automatically remove old database dumps from the given filesystem. This currently only supports keeping the latest N files. If custom "algorithms" are desired, see CleanupAlgorithmInterface to implement your own.

This tool currently supports MySQL 8 / MariaDB 10 databases. To implement more database platforms, see DumperInterface and MySQLDumper for a reference implementation.

How To use

version: '3.8'

services:
    db_dumper:
        image: danielburger1337/database-dumper

        # The container automatically shutsdown after a period of time to prevent memory leaks
        # Therefor it must be restarted automatically.
        restart: unless-stopped

        logging:
            driver: 'json-file'
            options:
                max-size: '200k'
                max-file: '3'

        environment:
            # By default the database dumps will be stored in the "/data" directory
            - DB_DUMPER_FILESYSTEM_DSN=local://local/data

            # See src/FilesystemFactory/FtpFilesystemFactory.php for all options
            # - DB_DUMPER_FILESYSTEM_DSN=ftp://user:[email protected]
            # - DB_DUMPER_FILESYSTEM_DSN=ftps://user:[email protected]/directory-path

            # See src/FilesystemFactory/SftpFilesystemFactory.php for all options
            # - DB_DUMPER_FILESYSTEM_DSN=sftp://user:[email protected]/

            # Disable compressing the database dump (enabled by default)
            # - DB_DUMPER_ENABLE_GZIP=false

            # Database connection DSN (this will dump all databases)
            - DB_DUMPER_COMMAND=mysql://[email protected]
            # This will only dump the "my-database-name" database
            # - DB_DUMPER_COMMAND=mysql://[email protected]:3306/my-database-name
            # This will dump the "my-database-name" and "my-other-database-name" databases
            # - DB_DUMPER_COMMAND=mysql://[email protected]:3306/my-database-name,my-other-database-name

            # Cron-Expression for when the database should be dumped
            # - DB_DUMPER_SCHEDULE=0 0 * * *

            # Cron-Expression for when old database dumps should be removed
            # Set this to an empty string to disable deleting old dumps
            # - DB_DUMPER_CLEANUP_SCHEDULE=30 0 * * *

            # How many old database dumps should be kept (default 5)
            # This option only has an effect if "DB_DUMPER_CLEANUP_SCHEDULE" is defined
            # and "DB_DUMPER_CLEANUP_ALGORITHM" is "keep_latest"
            # - DB_DUMPER_CLEANUP_KEEP_LATEST_COUNT=5

            # Optional: Encrypt the database dump with the following password
            # - DB_DUMPER_ENCRYPTION_PASSWORD=123456
            # openssl enc -d -pbkdf2 -aes-256-cbc -in your_dump.sql.enc -out your_dump.sql -k 123456

        # A volume mount is only required if the local filesystem adapter is used.
        # Make sure to mount the same path as used in your "DB_DUMPER_FILESYSTEM_DSN"
        # environment variable.
        volumes:
            - './local-data-mount:/data'

database-dumper's People

Contributors

danielburger1337 avatar dependabot[bot] avatar

Watchers

 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.