Configuration
GoBackup will read config from following paths:
~/.gobackup/gobackup.yml
/etc/gobackup/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
Field | Type | Description | Default |
---|---|---|---|
web | WebConfig | Web server config | |
workdir | string | Special 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 | []ModelConfig | Model configs, see: ModelConfig | [] |
WebConfig
Field | Type | Description | Default |
---|---|---|---|
host | string | Web server host | 127.0.0.1 |
port | string | Web server port | 2703 |
username | string | Web server Basic Auth username. | |
password | string | Web server Basic Auth password. |
ModelConfig
Field | Type | Description | Default |
---|---|---|---|
description | string | The description of this model. | |
schedule | ScheduleConfig | Schedule config | |
databases | []DatabaseConfig | Database configs, see: DatabaseConfig | |
default_storage | string | The default storage name. | |
storages | []StorageConfig | see: StorageConfig | |
notifiers | []NotifierConfig | see: NotifierConfig | |
compress_with | CompressConfig | Compressor config | |
encrypt_with | EncryptConfig | Encryptor config | |
archive | ArchiveConfig | Archive config | |
split_with | SplitConfig | Split config | |
before_script | string | Run script before this model perform backup. | |
after_script | string | Run 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.:
- Stop database service;
- Backup;
- 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
Field | Type | Description | Default |
---|---|---|---|
type | string | Database type, e.g.: mysql |
More about database please checkout databases doc.
StorageConfig
Field | Type | Description | Default |
---|---|---|---|
type | string | Storage provider type, e.g.: s3 |
More about database please checkout storages doc.
NotifierConfig
Field | Type | Description | Default |
---|---|---|---|
type | string | Notifier type, e.g.: github | |
on_success | bool | Enable or disable notify on backup success. | true |
on_failure | bool | Enable or disable notify on backup failure. | true |
CompressConfig
Field | Type | Description | Default |
---|---|---|---|
type | string | The compress type. |
EncryptConfig
Field | Type | Description | Default |
---|---|---|---|
type | string | The encrypt type. |
ArchiveConfig
Field | Type | Description | Default |
---|---|---|---|
includes | []string | Paths or filenames want to archive. | |
excludes | []string | Paths or filenames want to excludes. |
SplitConfig
Field | Type | Description | Default |
---|---|---|---|
chunk_size | int | Number of chunks to split. | |
suffix_length | int | Special that the part file name suffix number length. | 3 |
numeric_suffixes | bool | Use numeric suffix. | true |
ScheduleConfig
Field | Type | Description | Default |
---|---|---|---|
cron | string | Config cron rule, if you want use cron format schedule, keep empty will use every , at . | |
every | string | Every 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". | |
at | string | At 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)