Download the PHP package marekmiklusek/database-backup without Composer

On this page you can find all versions of the php package marekmiklusek/database-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package database-backup

image(1)(2)

Laravel Database Backup πŸ’ΎπŸ“‚πŸŒ

A lightweight package for automated MySQL database backups in Laravel applications. This package seamlessly integrates with both local storage and Google Drive, providing a reliable solution for database backup management.

Features

System Requirements

Ensure your system meets the minimum version requirements before installing this package.

Installation

Step 1: Install the Package

Step 2: Publish Configuration

Local Backup Configuration

Backups are stored locally by default using the local disk.

Usage

Run a Backup

To create a new backup, run the following Artisan command:

Clean Up Old Backups

Disabling Automatic Cleanup

If you want to disable automatic cleanup, you can set the automatic option to false in the configuration file:

If you prefer to manually clean up old backups, you can run the following Artisan command:

Google Drive Integration

Step 1: Configure Google Drive

Add the following configuration to config/filesystems.php:

NOTE: you can customize the disk name (e.g., google_db_backup instead of google)

Step 2: Environment Variables

Add these variables to your .env file:

Google Drive API Setup Guide

This guide will walk you through setting up Google Drive API credentials and obtaining the necessary tokens for integration with your Laravel application.

Step 1: Create Google Cloud Project

  1. Visit Google Cloud Console
  2. Click "Select a project" β†’ "New Project"
  3. Enter a project name and click "CREATE"
  4. Wait for the project to be created and select it

Step 2: Enable Google Drive API

  1. In the left sidebar, navigate to "APIs & Services" β†’ "Library"
  2. Search for "Google Drive API"
  3. Click on "Google Drive API"
  4. Click "ENABLE"

Step 3: Configure OAuth Consent Screen

  1. Go to "APIs & Services" β†’ "OAuth consent screen"
  2. Select "External" user type and click "CREATE"
  3. Fill in the required information:
    • App name
    • User support email
    • Developer contact information
  4. Click "SAVE AND CONTINUE"
  5. Skip scopes screen by clicking "SAVE AND CONTINUE"
  6. Add test users (your email) if in testing mode
  7. Click "SAVE AND CONTINUE"

Step 4: Create Credentials

For Web Application:

  1. Go to "APIs & Services" β†’ "Credentials"
  2. Click "+ CREATE CREDENTIALS" β†’ "OAuth client ID"
  3. Select "Web application" as application type
  4. Enter a name for your client
  5. Under "Authorized redirect URIs" add:

  6. Click "CREATE"
  7. A popup will show your Client ID and Client Secret
  8. Add them to your .env file as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

For Desktop Application:

  1. Go to "APIs & Services" β†’ "Credentials"
  2. Click "+ CREATE CREDENTIALS" β†’ "OAuth client ID"
  3. Select "Desktop app" as application type
  4. Enter a name for your client
  5. Click "CREATE"
  6. A popup will show your Client ID and Client Secret
  7. Add them to your .env file as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

Step 5: Get Refresh Token

For Web Application:

  1. Go to Google OAuth Playground
  2. Click the gear icon (βš™οΈ) in the top right corner
  3. Check "Use your own OAuth credentials"
  4. Enter your:
    • OAuth Client ID
    • OAuth Client Secret
  5. Click "Close"
  6. In the left sidebar, find "Drive API v3"
  7. Select https://www.googleapis.com/auth/drive.file
  8. Click "Authorize APIs"
  9. Log in with your Google account and accept permissions
  10. Click "Exchange authorization code for tokens"
  11. Copy the refresh token from the response and add it to your .env file as GOOGLE_REFRESH_TOKEN

For Desktop Application:

  1. Open the following URL in your web browser (replace YOUR_CLIENT_ID with your actual client ID): https://accounts.google.com/o/oauth2/auth?client_id=YOUR_CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive.file&access_type=offline&prompt=consent
    • Using the scope https://www.googleapis.com/auth/drive.file allows your application to view and manage Google Drive files and folders that were opened or created by the app
  2. Sign in with your Google account and grant access to the requested permissions
  3. Google will display an authorization code on the screen. Copy this code
  4. In your terminal run the following curl command, to exchange the authorization code for tokens (replace YOUR_AUTHORIZATION_CODE, YOUR_CLIENT_ID, and YOUR_CLIENT_SECRET with the actual values):

  5. The response will include a refresh token. Copy it and store it in your .env file as GOOGLE_REFRESH_TOKEN

Step 6: Get Google Drive Folder ID

  1. Go to Google Drive
  2. Create a new folder or select an existing one for backups
  3. Open the folder
  4. Copy the folder ID from the URL
    • The URL will look like: https://drive.google.com/drive/folders/1A2B3C4D5E6F7...
    • The folder ID is the string after /folders/
  5. Add this folder ID to your .env file as GOOGLE_FOLDER_ID

That's it! πŸš€ You're now ready to use this package β€” have fun and enjoy! πŸ˜ŠπŸŽ‰

Events

This package emits the following events that you can listen to in your application:

Triggered when a database backup is successfully created.

Triggered when a database backup fails.

Common Issues

  1. Redirect URI Mismatch: Make sure you've added the exact OAuth Playground URL to authorized redirect URIs
  2. Invalid Credentials: Double-check all IDs and tokens are copied correctly
  3. Token Expiration: Refresh tokens don't expire unless revoked, but if you create new credentials, you'll need a new refresh token
  4. Permission Issues: Ensure the Google Drive API is enabled and the correct scope is selected

Security Notes

License

The MIT License (MIT). Please see License File for more information.


All versions of database-backup with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.31
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marekmiklusek/database-backup contains the following files

Loading the files please wait ....