{"id":18332076,"url":"https://github.com/sowrensen/butler","last_synced_at":"2026-04-05T21:32:13.787Z","repository":{"id":147630816,"uuid":"233790666","full_name":"sowrensen/butler","owner":"sowrensen","description":"Take mysql or mariadb database backup for your Laravel apps altogether. ","archived":false,"fork":false,"pushed_at":"2020-05-13T23:24:13.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-03T19:24:34.316Z","etag":null,"topics":["cronjob","data-rescue","data-storage","database","database-backups","laravel","laravel-framework","mariadb","mysql","sql"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sowrensen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-14T08:14:49.000Z","updated_at":"2020-05-13T23:24:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ddd1759-3d05-4fc6-a1f8-85df083d8e79","html_url":"https://github.com/sowrensen/butler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sowrensen/butler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Fbutler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Fbutler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Fbutler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Fbutler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sowrensen","download_url":"https://codeload.github.com/sowrensen/butler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Fbutler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31451438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cronjob","data-rescue","data-storage","database","database-backups","laravel","laravel-framework","mariadb","mysql","sql"],"created_at":"2024-11-05T19:37:15.473Z","updated_at":"2026-04-05T21:32:13.765Z","avatar_url":"https://github.com/sowrensen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Butler\n\nThis script takes the **mysql** or **mariadb** database backups of multiple **Laravel** apps as SQL \nfiles. Define the project `root` and `depth` in .env file and run the script as a cron job.\n\nChangelog\n------\n\n#### Version 1.5\n- Application now solely uses `dotenv` library to read `.env` file.\n- Added `requirements.txt` for using without Pipenv.\n\n#### Version 1.4\n \n - Improved process management.\n - Now `telescope:prune` command will only run when it is applicable, i.e. `telescope` is installed.\n - Code refactoring.\n\n#### Version 1.3\n \n - Added `laravel-telescope` data pruning support.\n - Improved code structure.\n - Fixed documentation.\n\n#### Version 1.2\n\n - Added option to remove older backups.\n - Now optional keys need not have to be specified in `.env` file.  \n - Improved visual feedback.\n\n#### Version 1.1\n\n - Added option to enable or disable generated file compression.\n\n#### Version 1.0\n\n - Initial release\n\nUsage\n------\n\n### Setup\n\nRun following commands in your terminal to copy this repository and for primary setup. I assume \nthat **mysql** or **mariadb** is installed on your machine, cause the script uses `mysqldump` \nunder the hood to take the backup. You will need [Pipenv](https://github.com/pypa/pipenv) \nto use this script however.\n\n```shell\ngit clone https://github.com/sowrensen/butler.git\ncd butler\npipenv install\ncp .env.example .env\n```\n\n### Enviroment Variables\n\nBefore you can run the script, you have to declare some environment variables in a \n`.env` file. An example `.env` file has been added for your consistency. Just copy\nthe `.env.example` file as `.env` and define the values for the following keys.\n\n\n - **PROJECT_ROOT** (required): This will be the directory where all of your Laravel projects \n reside, e.g. `/home/\u003cuser\u003e/projects`, or `/var/www`, or `/usr/share/nginx`. \n Note that, if you keep your projects into some place which is in `root` directory, \n you have to run the script as root. You know how Linux works, right?\n \n - **PROJECT_DEPTH** (required): This value defines the searching depths for directories.\n The value should be either 1 or 2. If you have subdirectories in your root \n directory, you have to put 2, else put 1. For example, suppose this is the file\n structure inside your `PROJECT_ROOT`:\n \n   ```\n   App-1/\n    - App_1_Instance_1/\n    - App_1_Instance_2/\n   App-2/\n    - App_2_Instance_1/\n    - App_2_Instance_2/\n   ``` \n   \n   In the above case, you have to put depth value 2. If there is only one\n   level of application directory, you can put 1.\n\n - **COMPRESS_OUTPUT** (optional, default=1): Self explanatory. By default compression is enabled. \n If you want to disable compression and prefer raw SQL output, set the value to anything other than 1.\n \n - **REMOVE_OLDER_FILES** (optional, default=0): This key takes number of days as input. By default it \n is disabled. If you specify any other number, the script will remove files generated before specified \n number of days. So if you specify 10, it will delete all backups generated before 10 days from next run.\n \n - **PRUNE_TELESCOPE_DATA** (optional, default=-1): If you're using Laravel Telescope in\n your project, this option might come handy. Specify any number (starting from 0) as value\n of this key and butler will run `php artisan telescope:prue --hours=number` for your project.\n By default it is disabled. _Note that, if telescope is not installed in some of your project\n it will not run for those projects._\n\nOutput\n------\nThe script will read the database credentials from each of your projects `.env` file and will use it\nto generate compressed SQL files along with all of your schemas and data for each of your projects.\nYou will get the generated SQL file inside each of your projects `storage/app/backup` directory. \n_Note that, these files will not be replaced in the next run, instead a new backup will be \ngenerated and stored_. The default file naming format is:\n\n```\n\u003cdbname\u003e_2020-01-14_13_45_06.[gz|sql]\n```\n\nYou can use these SQL files to restore data anytime.\n\nCron Example\n------------\n\nYou can run the file directly from cron job. However, if you face difficulties to run pipenv from \ncron, better you create a bash script like this.\n\n```\n#!/bin/sh\n\nPYTHON=\"/path/to/pipenv/python\"\nBUTLER=\"/path/to/butler\"\nPIPENV=\"/path/to/pipenv\"\nSCRIPT=\"butler.py\"\n\ncd \"${BUTLER}\" \u0026\u0026 \"${PIPENV}\" run \"${PYTHON}\" \"${SCRIPT}\"\n```\n\nMake the bash script executable by running:\n\n```shell\nchmod +x butler.sh\n```\n\nNow run the bash script as cron job. This following cron job will run on every **two days** at **03:30 AM** \nand write the log into the defined log file.\n\n```\n30 3 */2 * * /path/to/bash/butler.sh \u003e /path/to/butler_output.log\n```\n\nIf you do not want a log file:\n\n```\n30 3 */2 * * /path/to/bash/butler.sh \u003e/dev/null 2\u003e\u00261\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsowrensen%2Fbutler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsowrensen%2Fbutler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsowrensen%2Fbutler/lists"}