DEV Community

Cover image for Backup - Action
Valerian Pereira
Valerian Pereira

Posted on

Backup - Action

GitHub Action for backing up DB & Directories at regular intervals.

Uses

GitHub logo appleboy / drone-ssh

Drone plugin for executing remote ssh commands

Heads up !! Notes

This action backups the things and store it to /github/workspace/backups folder inside the container. You can attach several actions available at the Marketplace and store this backup to your choice of location.

Pre Requisites

My Workflow / Example Usage

Action Name: Backup-Action

Feel free to contribute.

name: backup db
on:
  schedule:
    - cron: "0 10 * * 1" # Every Monday at 10 AM UTC
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: Backup MySQL DB
      uses: valerianpereira/backup-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}
        port: ${{ secrets.PORT }}
        key: ${{ secrets.DEPLOY_KEY }}
        type: db
        db_type: mysql
        db_user: ${{ secrets.MYSQL_USER }}
        db_pass: ${{ secrets.MYSQL_PASS }}
        db_port: 3306
        db_name: world

Output:

DB type: mysql
🏃‍♂️ Running commands over ssh...
======CMD======
mysqldump -q -u *** -P 3306 -p'***' world | gzip -9 > mysql-world.1109201613.sql.gz
======END======
err: mysqldump: [Warning] Using a password on the command line interface can be insecure.
==============================================
✅ Successfully executed commands to all host.
==============================================
🔑 Loading the deploy key...
Done!! 🍻
🔄 Sync the mysql backups... 🗄
Warning: Permanently added '***' (ECDSA) to the list of known hosts.
receiving incremental file list
mysql-world.1109201613.sql.gz
              0   0%    0.00kB/s    0:00:00  
        623.78K  18%  605.53kB/s    0:00:04  
          3.45M 100%    2.32MB/s    0:00:01 (xfr#1, to-chk=0/1)
sent 51 bytes  received 3.46M bytes  628.39K bytes/sec
total size is 3.45M  speedup is 1.00
🤔 Whats the location of backups...
/github/workspace/backups
🔍 Show me backups... 😎
total 3M     
-rw-r--r--    1 ***     ***        3.3M Sep 11 16:14 mysql-world.1109201613.sql.gz

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo valerianpereira / backup-action

Action to backup directories and databases to a Github repository

🗄️ backup-action

GitHub Action for backing up DB & Directories.

First of all, Thanks 🙏 to @appleboy for drone-ssh & ssh-action to make this happen.

Heads up !! Notes

This action backups the things and store it to /github/workspace/backups folder inside the container. You can attach several actions available at the Marketplace and store this backup to your choice of location.

Pre Requisites

Example Usecase

name: backup db
on
  schedule
    - cron: "0 10 * * 1" # Every Monday at 10 AM UTC
jobs
  build
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: Backup MySQL DB
      uses: valerianpereira/backup-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}
        port: ${{ secrets.PORT }}
        key: ${{ secrets.DEPLOY_KEY }}
        type: db

Additional Resources / Info / Usecases

Collaborators

valerianpereira image

dr5hn image

Top comments (0)