Compare commits

...

19 Commits

Author SHA1 Message Date
01efeab13f update CI config
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-20 00:21:50 -06:00
9a663f4260 update docs
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-20 00:19:40 -06:00
7c635c36e0 update docs 2024-11-20 00:18:15 -06:00
fff33849da update docs and CI config
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-20 00:13:20 -06:00
3391ffa4e6 Revert "update docs and CI config"
This reverts commit b7d1be495e.
2024-11-20 00:10:29 -06:00
b7d1be495e update docs and CI config 2024-11-20 00:08:16 -06:00
2daf2f130d update docs
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-20 00:00:14 -06:00
d120c2ca8f update changelog and add link in docs
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-19 23:56:09 -06:00
02fd04930d update CI config
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
2024-11-19 23:52:14 -06:00
10b0abe707 update CI config 2024-11-19 23:49:00 -06:00
291a954e9c update CI config
Some checks failed
ci/woodpecker/tag/go-lint Pipeline failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/release/go-lint Pipeline failed
2024-11-19 23:30:33 -06:00
e43eecf383 update CI config
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/go-lint Pipeline failed
2024-11-19 23:22:00 -06:00
ea676fe0da add version to CI configs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/go-lint Pipeline failed
2024-11-19 23:08:34 -06:00
e73bd9ff3b update docs
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/tag/gitea Pipeline failed
ci/woodpecker/tag/go-lint Pipeline failed
2024-11-19 22:49:11 -06:00
fd9426181f update changelog 2024-11-19 20:22:20 -06:00
c25edc5d78 add changelog 2024-11-19 20:19:48 -06:00
aebfbda64e add changelog 2024-11-19 20:19:38 -06:00
5fe0629b0f update version and docs 2024-11-19 20:17:03 -06:00
7d6acd77b5 update version 2024-11-19 14:25:00 -06:00
18 changed files with 98 additions and 33 deletions

View File

@ -1,3 +0,0 @@
kind: Added
body: Lists config can now go in a file. See docs for more information.
time: 2024-08-28T14:27:30.427754114-05:00

View File

@ -1,3 +0,0 @@
kind: Added
body: 'new commands.[name].type: script. Works just like scriptFile, but can take arguments.'
time: 2024-10-08T22:37:33.664140846-05:00

View File

@ -1,3 +0,0 @@
kind: Added
body: Hooks for Commands.[name]. Error, success, and final. [#12]
time: 2024-11-14T21:01:48.823426401-06:00

View File

@ -1,3 +0,0 @@
kind: Changed
body: GetKnownHosts is now a method of Host
time: 2024-05-14T19:58:17.516072381-05:00

View File

@ -1,3 +0,0 @@
kind: Fixed
body: make command logger be used for errors, not just when running the command
time: 2024-11-14T21:13:06.404134926-06:00

9
.changes/v0.5.0.md Normal file
View File

@ -0,0 +1,9 @@
## v0.5.0 - 2024-11-19
### Added
* Lists can now go in a file. See docs for more information.
* commands.[name].type: script now opens `scriptEnvFile`.
* Hooks for Commands.[name]. Error, success, and final. [#12]
### Changed
* GetKnownHosts is now a method of Host
### Fixed
* make command logger be used for errors, not just when running the command

View File

@ -1,3 +1,4 @@
version: 2
before: before:
hooks: hooks:
# You may remove this if you don't use go modules. # You may remove this if you don't use go modules.
@ -31,9 +32,9 @@ archives:
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot: snapshot:
name_template: "{{ incpatch .Version }}-next" version_template: "{{ incpatch .Version }}-next"
changelog: changelog:
skip: false disable: false
gitea_urls: gitea_urls:
api: https://git.andrewnw.xyz/api/v1 api: https://git.andrewnw.xyz/api/v1

View File

@ -1,5 +1,6 @@
# This is an example .goreleaser.yml file with some sensible defaults. # This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com # Make sure to check the documentation at https://goreleaser.com
version: 2
before: before:
hooks: hooks:
# You may remove this if you don't use go modules. # You may remove this if you don't use go modules.
@ -32,7 +33,7 @@ archives:
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot: snapshot:
name_template: "{{ incpatch .Version }}-next" version_template: "{{ incpatch .Version }}-next"
changelog: changelog:
sort: asc sort: asc
filters: filters:

View File

@ -7,4 +7,8 @@ steps:
release: release:
image: golangci/golangci-lint:v1.53.3 image: golangci/golangci-lint:v1.53.3
commands: commands:
- golangci-lint run -v --timeout 5m - golangci-lint run -v --timeout 5m
when:
- event: push
branch: develop

View File

@ -5,6 +5,10 @@ steps:
- git submodule foreach 'git fetch origin; git checkout $(git describe --tags `git rev-list --tags --max-count=1`);' - git submodule foreach 'git fetch origin; git checkout $(git describe --tags `git rev-list --tags --max-count=1`);'
- cd docs - cd docs
- hugo - hugo
when:
- event: push
branch: master
path: "docs/*"
deploy: deploy:
image: codingkoopa/git-rsync-openssh image: codingkoopa/git-rsync-openssh
@ -23,8 +27,7 @@ steps:
- rsync -atv --delete --progress vangen/ backy@backy.cybershell.xyz:vangen-go - rsync -atv --delete --progress vangen/ backy@backy.cybershell.xyz:vangen-go
secrets: [ ssh_host_key, ssh_deploy_key, ssh_passphrase ] secrets: [ ssh_host_key, ssh_deploy_key, ssh_passphrase ]
when:
when: - event: push
- event: push branch: master
branch: master path: "docs/*"
path: "docs/*"

View File

@ -6,6 +6,30 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie). and is generated by [Changie](https://github.com/miniscruff/changie).
## v0.5.0 - 2024-11-19
### Added
* Lists can now go in a file. See docs for more information.
* commands.[name].type: script now opens `scriptEnvFile`.
* Hooks for Commands.[name]. Error, success, and final. [#12]
### Changed
* GetKnownHosts is now a method of Host
### Fixed
* make command logger be used for errors, not just when running the command
## v0.4.0 - 2023-09-08
### Added
* Added `scriptEnvFile` to command object that allows one to specify an environment file (or any file really) when a `scriptFile` is run. Inspired by the practice of keeping environment variables and scripts or commands seperate.
* Basis for listing commands
### Changed
* BREAKING: Notifications object now takes the form of service.id, where service can be "mail" or "matrix" and id is a unique id for the service.
* BREAKING: Since the change to the notifications object, cmd-lists' inner map key 'notifications' must be of the form service.id. id must be defined for that service. See notifications docs for aviliable services.
* Config parser is now the simpler Koanf - Keys are now case-sensitive
* Log size limited to 50 Mb
## v0.3.1 - 2023-07-20 ## v0.3.1 - 2023-07-20
### Changed ### Changed
* If an SSH session failed to be created, the command would fail. This would be caused when restarting the SSH host. The SSH connection is attempted to be created again. If successful, the command is executed normally. * If an SSH session failed to be created, the command would fail. This would be caused when restarting the SSH host. The SSH connection is attempted to be created again. If successful, the command is executed normally.

View File

@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
const versionStr = "0.4.0" const versionStr = "0.5.0"
var ( var (
versionCmd = &cobra.Command{ versionCmd = &cobra.Command{

2
docs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
public/
resources/_gen

View File

@ -7,6 +7,8 @@ Backy is a tool for automating data backup and remote command execution. It can
Why the name Backy? Because I wanted an app for backups. Why the name Backy? Because I wanted an app for backups.
View the [changelog here](https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/CHANGELOG.md).
{{% notice tip %}} {{% notice tip %}}
Feel free to open a [PR](https://git.andrewnw.xyz/CyberShell/backy/pulls), raise an [issue](https://git.andrewnw.xyz/CyberShell/backy/issues "Open a Gitea Issue")(s), or request new feature(s). Feel free to open a [PR](https://git.andrewnw.xyz/CyberShell/backy/pulls), raise an [issue](https://git.andrewnw.xyz/CyberShell/backy/issues "Open a Gitea Issue")(s), or request new feature(s).
{{% /notice %}} {{% /notice %}}

View File

@ -110,6 +110,7 @@ Usage:
backy list [--list=list1,list2,... | -l list1, list2,...] [ -cmd cmd1 cmd2 cmd3...] [flags] backy list [--list=list1,list2,... | -l list1, list2,...] [ -cmd cmd1 cmd2 cmd3...] [flags]
Flags: Flags:
-c, --cmds strings Accepts comma-separated names of commands to list.
-h, --help help for list -h, --help help for list
-l, --lists strings Accepts comma-separated names of command lists to list. -l, --lists strings Accepts comma-separated names of command lists to list.

View File

@ -12,10 +12,10 @@ To use a specific file:
If you leave the config path blank, the following paths will be searched in order: If you leave the config path blank, the following paths will be searched in order:
- `./backy.yml` 1. `./backy.yml`
- `./backy.yaml` 2. `./backy.yaml`
- `~/.config/backy.yml` 3. `~/.config/backy.yml`
- `~/.config/backy.yaml` 4. `~/.config/backy.yaml`
Create a file at `~/.config/backy.yml`. Create a file at `~/.config/backy.yml`.

View File

@ -9,6 +9,11 @@ Command lists are for executing commands in sequence and getting notifications f
The top-level object key can be anything you want but not the same as another. The top-level object key can be anything you want but not the same as another.
Lists can go in a separate file. Command lists should be in a separate file if:
1. key 'cmd-lists.file' is found
2. hosts.yml or hosts.yaml is found in the same directory as the backy config file
```yaml ```yaml
test2: test2:
name: test2 name: test2
@ -51,7 +56,7 @@ An array of notification IDs to use on success and failure. Must match any of th
### Name ### Name
Name is optional for logging. If name is not defined, name will be the object's map key. Name is optional. If name is not defined, name will be the object's map key.
### Cron mode ### Cron mode

View File

@ -19,7 +19,14 @@ commands:
- down - down
# if host is not defined, command will be run locally # if host is not defined, command will be run locally
# The host has to be defined in either the config file or the SSH Config files # The host has to be defined in either the config file or the SSH Config files
host: some-host host: some-host
hooks
error:
- some-other-command-when-failing
success:
- success-command
final:
- final-command
backup-docker-container-script: backup-docker-container-script:
cmd: /path/to/local/script cmd: /path/to/local/script
# script file is input as stdin to SSH # script file is input as stdin to SSH
@ -41,6 +48,7 @@ Values available for this section:
| `host` | If not specified, the command will execute locally. | `string` | no | | `host` | If not specified, the command will execute locally. | `string` | no |
| `scriptEnvFile` | When type is `scriptFile`, the script is appended to this file. | `string` | no | | `scriptEnvFile` | When type is `scriptFile`, the script is appended to this file. | `string` | no |
| `shell` | Only applicable when host is not specified | `string` | no | | `shell` | Only applicable when host is not specified | `string` | no |
| `hooks` | Hooks are used at the end of the individual command. Must be another command. | `[]string` | no |
#### cmd #### cmd
@ -93,9 +101,9 @@ Make sure to escape any shell input.
Path to a file. Path to a file.
When type is `scriptFile`, the script is appended to this file. When type is specified, the script is appended to this file.
This is useful for specifiing environment variables or other things so they don't have to be included in the script. This is useful for specifying environment variables or other things so they don't have to be included in the script.
### type ### type
@ -116,3 +124,23 @@ For now, the variables have to be defined in an `.env` file in the same director
If using it with host specified, the SSH server has to be configured to accept those env variables. If using it with host specified, the SSH server has to be configured to accept those env variables.
If the command is run locally, the OS's environment is added. If the command is run locally, the OS's environment is added.
### hooks
Hooks are run after the command is run.
Errors are run if the command errors, success if it returns no error. Final hooks are run regardless of error condition.
Values for hooks are as follows:
```yaml
command:
hook:
# these commands are defined elsewhere in the file
error:
- errcommand
success:
- successcommand
final:
- donecommand
```