The idea is to have a way ton backup servers with the same script and to keep the same tree folders. The couple restic
and rclone is a good way to backup, and this script can automate and send email reports.
The project is not maintained, but feel free to contribute and improve it !
# Locate where your rclone is configured
/BUCKET_NAME
|__ CLIENT_NAME
|__ SERVER_NAME
|__ REPO_NAME- restic
- rclone
- go1.16
$ git clone git@github.com:KeisukeFD/gobackup.git /home/scripts/backup
$ cd /home/scripts/backup
$ go build -o bin/gobackup# Get the lastest release from GitHub (https://github.com/restic/restic/releases)
Example:
$ curl -L https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_amd64.bz2 -o /tmp/restic_0.12.1_linux_amd64.bz2
$ bzip2 -d /tmp/restic_0.12.1_linux_amd64.bz2
$ mv /tmp/restic_0.12.1_linux_amd64 /usr/bin/restic$ curl https://rclone.org/install.sh | bashTwo ways:
- Use the command
rclone configand follow the steps (https://rclone.org/commands/rclone_config/) - If you already have a configuration file, put in
~/.config/rclone/rclone.conf
Note: The name of the connexion used by rclone will be use in the configuration file config.yml
as rclone_connection_name
---
information:
client_name:
server_name:
rclone_connection_name:
bucket_name:
exclusion_file:
keep_daily: 90 # 90 days by default
backup:
pre_exec:
post_exec:
binaries:
restic: "/usr/bin/restic"
email:
enabled: false
sender: "backups@local.dev"
password: ""
to: "you@gmail.com"
host: "127.0.0.1"
port: 1025
max_try: 5# Example:
RESTIC_PASSWORD="Encryption password" /home/scripts/backup/bin/gobackup -r Data /Backups /tomcat/conf /tomcat/lib
# Will backup into *Data* repository, all folders: /Backups, /tomcat/conf, /tomcat/libAt the first launch, you must initialize the restic repo. Then you will be able to put your command into cron to
automate your backups.
We've added a helper, to avoid to repeat the command, and parameters, and keep organized your folders. The helper reads the configuration file to know all your information, then you can use it like the following:
/home/scripts/backup/bin/gobackup -r Data snapshots$ bin/gobackup
Usage:
bin/gobackup [command]
Available Commands:
backup Backup with restic
completion generate the autocompletion script for the specified shell
help Help about any command
restic Restic helper command
Flags:
-c, --config string Configuration file in yaml format (default "config.yml")
-h, --help help for bin/gobackup
Use "bin/gobackup [command] --help" for more information about a command.$ bin/gobackup backup -h
Backup with restic, list of folders to backup in argument
Usage:
bin/gobackup backup [flags]
Flags:
-h, --help help for backup
--metrics-file string Export metrics file as Prometheus format (default "backup.prom")
-r, --repo string Restic repository name
Global Flags:
-c, --config string Configuration file in yaml format (default "config.yml")