Goback is a simple backup utility that generates zip files out of content.
Goback uses profile files to define the backup actions to perform, when invoking goback you can call a single profile file or a folder with profiles;
Important! all profiles withing a folder need to end with ".backup.yaml"
- First we create a profile with
goback generate > ./profilesDir/my-profile.backup.yaml
-
Now we edit according our needs, see [profile details](Profile Details) below
-
Now we can validate the configuration with
goback validate ./profilesdir/my-profile.backup.yaml
# or
goback validate ./profilesdir/
- To run the backup simply run
goback backup ./profilesdir/my-profile.backup.yaml
# or
goback backup ./profilesdir/
Currently, goback supports 3 types of profiles:
Local:
- intended to backup files on the same OS as the process runs
- Local backup is specified by the type
type: "Local" - mandatory fields:
dirsordbs,destination
Remote:
- opens an ssh connection to a target and runs the backup there, storing content locally
- remote backup is specified by the type
type: "remote" - mandatory fields:
dirsordbs,sshanddestination
sftpSync:
- connects to a remote target using SFTP, and pulls goback Backup files from remote to local. This is useful if you have a remote machine running local backups, and you want a way to pull them into another machine.
- specified by the type
type: "sftpsync" - mandatory fields:
dirsordbs,sshanddestination
---
version: 1
name: "remote"
type: "remote"
- name: the base name used when generating compressed files and identifying log lines
- type: specify the type of profile
dirs:
- dirs: is a list of directories to backup.
- path: root of the path to backup.
- exclude: a list of glob patterns of files to exclude from the backup.
- name: Only used in sftpsync, specify the name of the profile to pull
example:
dirs:
- path: "relative/path"
exclude:
- "*.log"
- path: "/backup/service2"
NOTE: if connecting to a sftp jail (sftpsync) the path needs to account for the jail root, E.g. if your jail is in /var/backups/content /that makes your new root /backups hence you need to put in path /content
dbs:
- dbs: list of databases to backup.
- dbname: database name
- type: database type, at the moment only mysql is supported, either directly or connecting to a docker container.
- user: database user to login to the db. Leave empty to let the tool try to get access.
- password: database user to login to the db. Leave empty to let the tool try to get access.
- containerName: the docker container name to run the db dump on
Note: goback will try to get root credentials for mysql from common locations like /etc/my.cnf a d fallback to socket login
IMPORTANT: mysql/maraibd uses mysqldump to add databases to the backup, this needs to be installed otherwise it will fail.
example:
dbs:
- name: dbname
type: mysql
user: user
password: pw
containerName: container
ssh:
- ssh: details about ssh/sftp connection
- type [ password | sshkey | sshagent ]: how to login to the remote server.
- host: ssh host
- port: ssh port
- user: ssh user
- password: plain text ssh password, used if type is sshPassword
- privateKey: path to a private key, used if type is sshKey
- passPhrase: plain text pass phrase to the private key
example:
ssh:
type: password
host: bla.ble.com
port: 22
user: user
password: pw
destination:
- destination: details about the backup files destination
- path: local path where backup files are created
- keep: how many older backups to keep for this profile, set to -1 to disable deletion.
- owner: change the owner of the resulting backup file
- mode: change the mode of the resulting backup file
example:
destination:
path: /backups
keep: 3
owner: "ble"
mode : "0600"
notify:
- notify: optional setting to send an email per profile
- to: list of email addresses to notify
- host: email server host
- port: email sever port
- user: email server user to login
- password: password for that user on the email server
- from: email From address
example:
notify:
host: smtp.mail.com
port: 587
to:
- mail1@mail.com
- mail2@mail.com
user: mail@mails.com
password: 1234
- backup git repositories
- backuo github orgs
- allow to use envs placeholders in profiles, e.g. for secrets
- exclude folders that contain .nobackup
- improve the expurge rules to keep N yearly, monthly etc
- use systemd timers instead of cron
- add option to follow symlink instead of adding them to the backup file
- use tar.gz instead of zip to keep file permissions
- don't fail on broken symlinks
- go
- make
- docker
- goreleaser
- golangci-lint
- git
make sure you have your gh token stored locally in ~/.goreleaser/gh_token
to release a new version:
make release version="v0.1.2"