gobackup

command module
v0.0.0-...-a6e6698 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 4 Imported by: 0

README

GoBackup

Simple tool for backup your databases, files to cloud storages.

GoBackup is a fullstack backup tool design for web servers similar with backup/backup, work with Crontab to backup automatically.

You can write a config file, run gobackup perform command by once to dump database as file, archive config files, and then package them into a single file.

It’s allow you store the backup file to local, FTP, SCP, S3 .

Forked from [https://github.com/auzty/gobackup]https://github.com/auzty/gobackup

Features

  • No dependencies.
  • Multiple Databases source support.
  • Multiple Storage type support.
  • Archive paths or files into a tar.

Current Support status

Databases

  • MySQL
  • PostgreSQL
  • Redis - mode: sync/copy
  • MongoDB

Archive

Use tar command to archive many file or path into a .tar file.

Compressor

  • Tgz - .tar.gz

Encryptor

  • OpenSSL - aes-256-cbc encrypt

Storages

  • Local
  • FTP
  • SCP - Upload via SSH copy
  • Amazon S3

Install (macOS / Linux)

$ go build -o backupnow
$ ./gobackup -h
NAME:
   gobackup - Easy full stack backup operations on UNIX-like systems

USAGE:
   gobackup [global options] command [command options] [arguments...]

VERSION:
   0.1.1

COMMANDS:
     perform
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Configuration

GoBackup will seek config files in:

  • ~/.gobackup/gobackup.yml
  • /etc/gobackup/gobackup.yml

Example config: gobackup_test.yml

models:
  gitlab:
    compress_with:
      type: tgz
    store_with:
      type: scp
      path: ~/backup
      host: your-host.com
      private_key: ~/.ssh/id_rsa
      username: ubuntu
      password: password
      timeout: 300
    databases:
      gitlab:
        type: mysql
        host: localhost
        port: 3306
        database: gitlab_production
        username: root
        password:
        additional_options: --single-transaction --quick
      gitlab_redis:
        type: redis
        mode: sync
        rdb_path: /var/db/redis/dump.rdb
        invoke_save: true
        password:
    archive:
      includes:
        - /home/git/.ssh/
        - /etc/mysql/my.conf
        - /etc/nginx/nginx.conf
        - /etc/nginx/conf.d
        - /etc/redis/redis.conf
        - /etc/logrotate.d/
      excludes:
        - /home/ubuntu/.ssh/known_hosts
        - /etc/logrotate.d/syslog

sample config with postgresql and send notifications to slack

models:
  base_test:
    compress_with:
      type: tgz
    notifications:
      type: slack
      webhook: https://slack.com/hooks/fakkefk3211211klfk
    store_with:
      type: local
      keep: 10
      path: /tmp/backupku
    databases:
      dummy_test:
        type: postgresql
        host: localhost
        port: 5432
        database: mylocaldb
        username: postgres
        password: password
        additional_options: -Fc
    archive:
      includes:
        - /tmp/jajalbackup/

Sample Usage

$ ./gobackup perform
2017/09/08 06:47:36 ======== ruby_china ========
2017/09/08 06:47:36 WorkDir: /tmp/gobackup/1504853256396379166
2017/09/08 06:47:36 ------------- Databases --------------
2017/09/08 06:47:36 => database | Redis: mysql
2017/09/08 06:47:36 Dump mysql dump to /tmp/gobackup/1504853256396379166/mysql/ruby-china.sql
2017/09/08 06:47:36

2017/09/08 06:47:36 => database | Redis: redis
2017/09/08 06:47:36 Copying redis dump to /tmp/gobackup/1504853256396379166/redis
2017/09/08 06:47:36
2017/09/08 06:47:36 ----------- End databases ------------

2017/09/08 06:47:36 ------------- Compressor --------------
2017/09/08 06:47:36 => Compress with Tgz...
2017/09/08 06:47:39 -> /tmp/gobackup/2017-09-08T14:47:36+08:00.tar.gz
2017/09/08 06:47:39 ----------- End Compressor ------------

2017/09/08 06:47:39 => storage | FTP
2017/09/08 06:47:39 -> Uploading...
2017/09/08 06:47:39 -> upload /ruby_china/2017-09-08T14:47:36+08:00.tar.gz
2017/09/08 06:48:04 Cleanup temp dir...
2017/09/08 06:48:04 ======= End ruby_china =======

Backup schedule

You may want run backup in scheduly, you need Crontab:

$ crontab -l
0 0 * * * /usr/local/bin/gobackup perform >> ~/.gobackup/gobackup.log

0 0 * * * means run at 0:00 AM, every day.

And after a day, you can check up the execute status by ~/.gobackup/gobackup.log.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL