Periodic Database Backup to Gitlab Private Repository Using Flysystem and Cronjob

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • flysystem-gitlab-storage

    Gitlab Storage filesystem for Flysystem (https://flysystem.thephpleague.com/docs/).

  • Flysystem Gitlab Adapter by Roy Voetman

  • mysqldump-php

    PHP version of mysqldump cli that comes with MySQL

  • Mysqldump PHP by ifsnop

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • profile

  • Visit Gitlab Access Token page and create your access token:

  • ntfy

    Send push notifications to your phone or desktop using PUT/POST

  • $db_host = 'YOUR_DB_HOST'; $db_user = 'YOUR_DB_USER'; $db_pass = 'YOUR_DB_PASS'; $db_name = 'YOUR_DB_NAME'; // Create database name $database_name = 'backup-on-YOUR-DB-NAME-'.date('d-m-Y').'.sql'; // Define path for dump on disk $app_path = 'YOUT_PATH'; if ( file_exists($app_path . $database_name) ) { $database_name = date('His').'-'.$database_name; // Dump database $dump = new IMysqldump\Mysqldump('mysql:host='. $db_host .';dbname='. $db_name .'', $db_user, $db_pass); $dump->start( $app_path . $database_name ); } else { // Dump database $dump = new IMysqldump\Mysqldump('mysql:host='. $db_host .';dbname='. $db_name .'', $db_user, $db_pass); $dump->start( $app_path . $database_name ); } $file_content = file_get_contents( $app_path . $database_name ); $dir_backup = 'db-'.strtolower(date('F-Y')); // Result like: db-december-2021 // Gitlab Flysystem Config $personal_access_token = "GITLAB_ACCESS_TOKEN"; $project_id = "PROJECT_ID"; $branch = "BRANCH_NAME"; $cloud_url = "https://gitlab.com"; // <-- default or use your gitlab instance url // Create a GitLab Client to talk with the API $client = new Client( $personal_access_token , $project_id, $branch, $cloud_url); // Create the Adapter that implements Flysystems AdapterInterface $adapter = new GitlabAdapter($client); // Use FileSystem $filesystem = new Filesystem($adapter); // Check if directory backup is exists on repository if ( $filesystem->has($dir_backup) ) { // If exists then write database inside $filesystem->write($dir_backup.'/'.$database_name, $file_content); } else { // If not exists then create directory $filesystem->createDir($dir_backup); // then write database inside $filesystem->write($dir_backup.'/'.$database_name, $file_content); } file_get_contents('https://ntfy.sh/', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . "Title: Daily Database Backup!\r\n" . "Priority: default\r\n" . "Tags: bell,tada,partying_face", 'content' => 'Backup successful 😀' ] ]));

  • Flysystem

    Abstraction for local and remote filesystems

  • Ok, I need the Flysystem Library to do CRUD transactions with the Gitlab API.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Where to store the user 's profile picture?

    1 project | /r/PHP | 19 Jan 2023
  • Laravel Cloudinary v2 Release Update

    2 projects | dev.to | 28 Jun 2022
  • How do you "simulate" failures in integration tests?

    1 project | /r/PHP | 30 Mar 2022
  • Is caching no longer available for Storage (S3)?

    2 projects | /r/laravel | 12 Mar 2022
  • ⚠️ A security advisory was created for league/flysystem. Please upgrade to 1.1.4 or 2.1.1.

    1 project | /r/laravel | 24 Jun 2021