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

Top comments (0)