Configuration
Overview

Configuration

GoBackup will read config from following paths:

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

You must use YAML (opens in a new tab) format.

Config file example

web:
  # host: your-host.com
  # port: 2703
  username: <your-name>
  password: <your-web-ui-password>
models:
  # special a model name
  model_name1:
    before_script: |
      # Run script before this model perform backup.
      echo "before script"
    after_script: |
      echo "after script"
    # config compress
    compress_with:
      # compress type
      type: tgz
    split_with:
      # Split backup file into multiple files, each file in 1gb.
      chunk_size: 1g
    # storage
    storages:
      ftp:
        # storage type
        type: ftp
        # other config for this storage type
        host: ftp.your-host.com
        username: ...
        password: ...
    # database source support multiple instance
    databases:
      # special a database name
      my_app1:
        # database type
        type: mysql
        # other config for this database type
        host: localhost
        database: my_app_production
        username: root
      my_app_redis1:
        type: redis
        host: localhost
        port: 6379
        mode: sync
      my_app_redis2:
        type: redis
        host: localhost
        port: 6380
        mode: sync
    # archive config
    archive:
      # archive multiple files / directoies
      includes:
        - /home/git/.ssh/
        - /etc/mysql/my.conf
        - /etc/nginx/nginx.conf
        - /etc/nginx/conf.d
        - /etc/redis/redis.conf
        - /etc/logrotate.d/
      # path will exclude
      excludes:
        - /home/ubuntu/.ssh/known_hosts
        - /etc/logrotate.d/syslog
  # another model
  my_app2:
    databases:
      mysql:
        type: mysql
        host: localhost
        database: my_app_production
      redis:
        type: redis
        host: localhost
        port: 6379
    compress_with:
      type: tgz
    default_storage: local_a
    storages:
      local_a:
        type: local
        path: /data/backups/my_app2
      cloud_s3:
        type: s3
        keep: 20
        bucket: your-bucket
        region: ap-southeast-1
        path: backups
        access_key_id: xxxxx
        secret_access_key: xxxxxxxx

More example: https://github.com/gobackup/gobackup/blob/main/gobackup_test.yml (opens in a new tab)

ENV variables

since: 1.6.0

GoBackup supports to use ENV variables in config, to keep secrets info more secure.

Use $ENV_KEY or ${ENV_KEY} to get ENV variables.

For example:

models:
  example:
    databases:
      postgresql:
        type: postgresql
        database: demo
        username: $POSTGRESQL_USERNAME
        password: $POSTGRESQL_PASSWORD
    storages:
      s3:
        type: s3
        bucket: gobackup-test
        region: ap-southeast-1
        path: backups
        access_key_id: $AWS_ACCESS_KEY_ID
        secret_access_key: ${AWS_SECRET_ACCESS_KEY}

Now you can set ENV in your bash or in .env file.

POSTGRESQL_USERNAME=postgres
POSTGRESQL_PASSWORD=this-is-my-password
AWS_ACCESS_KEY_ID=xxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxx

Config Keys

FieldTypeDescriptionDefault
webWebConfigWeb server config
workdirstringSpecial a work dir for GoBackup to generate some temp files.
e.g: /path/of/tmp/folder
Default is system tmp folder.
e.g. on Linux is: /tmp
models[]ModelConfigModel configs, see: ModelConfig[]

WebConfig

FieldTypeDescriptionDefault
hoststringWeb server host127.0.0.1
portstringWeb server port2703
usernamestringWeb server Basic Auth username.
passwordstringWeb server Basic Auth password.

ModelConfig

FieldTypeDescriptionDefault
descriptionstringThe description of this model.
scheduleScheduleConfigSchedule config
databases[]DatabaseConfigDatabase configs, see: DatabaseConfig
default_storagestringThe default storage name.
storages[]StorageConfigsee: StorageConfig
notifiers[]NotifierConfigsee: NotifierConfig
compress_withCompressConfigCompressor config
encrypt_withEncryptConfigEncryptor config
archiveArchiveConfigArchive config
split_withSplitConfigSplit config
before_scriptstringRun script before this model perform backup.
after_scriptstringRun script after this model perform backup.

Run script around backup performing

Since: v2.9.0

We have before_script and after_script for let us to special that run script before or after this model perform backup.

This is useful when you want to do something complex workflow, e.g.:

  1. Stop database service;
  2. Backup;
  3. Start database service again.
models:
  my_app:
    before_script: |
      # Stop database service
      systemctl stop mysql
    after_script: |
      # Start database service
      systemctl start mysql
    databases:
      mysql:
        type: mysql
        host: localhost
        database: my_app_production
        username: root

DatabaseConfig

FieldTypeDescriptionDefault
typestringDatabase type, e.g.: mysql

More about database please checkout databases doc.

StorageConfig

FieldTypeDescriptionDefault
typestringStorage provider type, e.g.: s3

More about database please checkout storages doc.

NotifierConfig

FieldTypeDescriptionDefault
typestringNotifier type, e.g.: github
on_successboolEnable or disable notify on backup success.true
on_failureboolEnable or disable notify on backup failure.true

CompressConfig

FieldTypeDescriptionDefault
typestringThe compress type.

EncryptConfig

FieldTypeDescriptionDefault
typestringThe encrypt type.

ArchiveConfig

FieldTypeDescriptionDefault
includes[]stringPaths or filenames want to archive.
excludes[]stringPaths or filenames want to excludes.

SplitConfig

FieldTypeDescriptionDefault
chunk_sizeintNumber of chunks to split.
suffix_lengthintSpecial that the part file name suffix number length.3
numeric_suffixesboolUse numeric suffix.true

ScheduleConfig

FieldTypeDescriptionDefault
cronstringConfig cron rule, if you want use cron format schedule, keep empty will use every, at.
everystringEvery schedules a new periodic Job with an interval.
Interval can be an int, time.Duration or a string that parses with time.ParseDuration(). Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
atstringAt schedules the Job at a specific time of day in the form "HH:MM:SS" or "HH:MM" or time.Time (note that only the hours, minutes, seconds and nanos are used).

More about schedule see: https://github.com/go-co-op/gocron (opens in a new tab)