captiolabs/backup-manager

A CLI tool to create and restore backups.

1.0.x-dev 2018-11-16 02:08 UTC

README

A CLI tool to create and restore local and off-site backups. Currently supports backing up files and MySQL databases.

Description

The Backup Manager currently support local and remote file and MySQL backups. The supported remote storage options are SFTP and WebDAV.

Requirements

  • PHP 7.2+
  • tar (available in $PATH)
  • gpg (available in $PATH)
  • mysqldump (available in $PATH)

Installation

  1. Run composer global require captiolabs/backup-manager.
  2. Make sure that your global Composer vendor directory is in your $PATH. If this is not the case run echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile.
  3. Reload your .bash_profile file by running source ~/.bash_profile
  4. Run backup-manager to start the application.

Configuration

Example configuration:

file:
  general:
    target:
      - /var/www
      - /var/log
    backup_name: backup_file
    backup_date: Y_m_d
    timeout: 600
  encryption:
    password: password
  local_storage:
    destination: /var/backup-manager/backup/file
    restore_location: /var/backup-manager/restore/file
    retention: 90
  remote_storage:
    destination: /var/backup-manager/backup/file
    retention: 90

mysql:
  general:
    backup_name: backup_mysql
    backup_date: Y_m_d
    host: host
    port: 3306
    username: backup
    password: password
    temporary_location: /tmp/backup-manager/mysql
    timeout: 600
  encryption:
    password: password
  local_storage:
    destination: /var/backup-manager/backup/mysql
    retention: 90
  remote_storage:
    destination: /var/backup-manager/backup/mysql
    retention: 90

remote_storage:
  type: webdav
  host: https://webdav.example.com/remote.php/webdav/
  username: username
  password: password

IMPORTANT: after making configuration changes please make sure that you clear application's cache by running backup-manager clear:cache!

Remote storage

Supported remote storage configurations:

SFTP

remote_storage:
  type: sftp
  host: host
  port: 22
  username: username
  password: password
  private_key: /home/user/.ssh/id_rsa
  timeout: 600

WebDAV

remote_storage:
  type: webdav
  host: https://webdav.example.com/remote.php/webdav/
  username: username
  password: password

IMPORTANT: currently only one remote storage option can be defined!

Usage

General

  • List available commands: backup-manager list

Backup

  • Start file backup: backup-manager backup:file
  • Start MySQL backup: backup-manager backup:mysql

List

  • List local file backups: backup-manager backup:list file local
  • List remote file backups: backup-manager backup:list file remote
  • List local MySQL backups: backup-manager backup:list mysql local
  • List remote MySQL backups: backup-manager backup:list mysql remote

Restore

  • Restore local file backups: backup-manager backup:restore file
  • Restore local MySQL backups: backup-manager backup:restore mysql