vanegmondgroep / backup-cli
An extendable command-line interface for backing up and restoring data using Restic.
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Shell
README
An extendable command-line interface for backing up and restoring data using Restic.
Install
Before installing Backup CLI, please make sure your environment meets the minimum requirements:
Once you’ve verified the requirements, download and install Backup CLI with Composer.
# Install Backup CLI package
composer require vanegmondgroep/backup-cli
By default, commands are invoked using the vendor/bin/bcli
script. However, instead of repeatedly
typing vendor/bin/bcli
to execute commands, you may wish to configure a shell alias that allows you to execute
commands more easily:
alias bcli='[ -f bcli ] && sh bcli || sh vendor/bin/bcli'
To make sure this is always available, you may add this to your shell configuration file in your home directory, such
as ~/.zshrc
or ~/.bashrc
, and then restart your shell.
Commands
# Backup a service bcli backup <service> # Display service snapshots bcli snapshots <service> # Restore a service bcli restore <service> <snapshot-id> # Display backup logs bcli logs <service>
Configuration
Backup CLI loads environment variables from a .env
file within the current working directory. The following variables
are available:
** This defines a service path you would like to back up (e.g. MYSQL_BACKUP_PATH
).
Hooks
Backup CLI calls scripts (hooks) before and after a backup or restore. This allows you to perform an action, such as exporting a database before a backup is made. The following hooks are available:
Logs
Logs are written to $BACKUP_LOGS_PATH/<service>.log
.
Example
The example configuration shows how you can back up / restore a MySQL and Node-RED container.
Cronjobs
To schedule a backup, add the following line to your crontab:
# Run MySQL backup every day at 01:00 0 1 * * * cd <project-dir> && vendor/bin/bcli backup mysql # Run Node-RED backup every day at 02:00 0 2 * * * cd <project-dir> && vendor/bin/bcli backup node-red