Skip to content

Commit

Permalink
rename backup hook attributes (#371)
Browse files Browse the repository at this point in the history
Co-authored-by: ibizaman <[email protected]>
  • Loading branch information
ibizaman and ibizaman authored Nov 26, 2024
1 parent 54b0cb6 commit ba1e60a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Template:

# Upcoming Release

## Breaking Changes

- Options `before_backup` and `after_backup` for backup contract have been renamed to
`beforeBackup` and `afterBackup`.

## Other Changes

- Show how to pin Self Host Blocks flake input to a tag.
Expand Down
40 changes: 20 additions & 20 deletions docs/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@
"blocks-restic-options-shb.restic.instances._name_.request.hooks": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.hooks"
],
"blocks-restic-options-shb.restic.instances._name_.request.hooks.after_backup": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.hooks.after_backup"
"blocks-restic-options-shb.restic.instances._name_.request.hooks.afterBackup": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.hooks.afterBackup"
],
"blocks-restic-options-shb.restic.instances._name_.request.hooks.before_backup": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.hooks.before_backup"
"blocks-restic-options-shb.restic.instances._name_.request.hooks.beforeBackup": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.hooks.beforeBackup"
],
"blocks-restic-options-shb.restic.instances._name_.request.sourceDirectories": [
"blocks-restic.html#blocks-restic-options-shb.restic.instances._name_.request.sourceDirectories"
Expand Down Expand Up @@ -581,11 +581,11 @@
"contracts-backup-options-shb.contracts.backup.request.hooks": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.hooks"
],
"contracts-backup-options-shb.contracts.backup.request.hooks.after_backup": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.hooks.after_backup"
"contracts-backup-options-shb.contracts.backup.request.hooks.afterBackup": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.hooks.afterBackup"
],
"contracts-backup-options-shb.contracts.backup.request.hooks.before_backup": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.hooks.before_backup"
"contracts-backup-options-shb.contracts.backup.request.hooks.beforeBackup": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.hooks.beforeBackup"
],
"contracts-backup-options-shb.contracts.backup.request.sourceDirectories": [
"contracts-backup.html#contracts-backup-options-shb.contracts.backup.request.sourceDirectories"
Expand Down Expand Up @@ -857,11 +857,11 @@
"services-forgejo-options-shb.forgejo.backup.hooks": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.hooks"
],
"services-forgejo-options-shb.forgejo.backup.hooks.after_backup": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.hooks.after_backup"
"services-forgejo-options-shb.forgejo.backup.hooks.afterBackup": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.hooks.afterBackup"
],
"services-forgejo-options-shb.forgejo.backup.hooks.before_backup": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.hooks.before_backup"
"services-forgejo-options-shb.forgejo.backup.hooks.beforeBackup": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.hooks.beforeBackup"
],
"services-forgejo-options-shb.forgejo.backup.sourceDirectories": [
"services-forgejo.html#services-forgejo-options-shb.forgejo.backup.sourceDirectories"
Expand Down Expand Up @@ -1331,11 +1331,11 @@
"services-nextcloudserver-options-shb.nextcloud.backup.hooks": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.hooks"
],
"services-nextcloudserver-options-shb.nextcloud.backup.hooks.after_backup": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.hooks.after_backup"
"services-nextcloudserver-options-shb.nextcloud.backup.hooks.afterBackup": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.hooks.afterBackup"
],
"services-nextcloudserver-options-shb.nextcloud.backup.hooks.before_backup": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.hooks.before_backup"
"services-nextcloudserver-options-shb.nextcloud.backup.hooks.beforeBackup": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.hooks.beforeBackup"
],
"services-nextcloudserver-options-shb.nextcloud.backup.sourceDirectories": [
"services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.backup.sourceDirectories"
Expand Down Expand Up @@ -1481,11 +1481,11 @@
"services-vaultwarden-options-shb.vaultwarden.backup.hooks": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.hooks"
],
"services-vaultwarden-options-shb.vaultwarden.backup.hooks.after_backup": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.hooks.after_backup"
"services-vaultwarden-options-shb.vaultwarden.backup.hooks.afterBackup": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.hooks.afterBackup"
],
"services-vaultwarden-options-shb.vaultwarden.backup.hooks.before_backup": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.hooks.before_backup"
"services-vaultwarden-options-shb.vaultwarden.backup.hooks.beforeBackup": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.hooks.beforeBackup"
],
"services-vaultwarden-options-shb.vaultwarden.backup.sourceDirectories": [
"services-vaultwarden.html#services-vaultwarden-options-shb.vaultwarden.backup.sourceDirectories"
Expand Down
12 changes: 6 additions & 6 deletions modules/blocks/borgbackup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ let
default = {};
type = lib.types.submodule {
options = {
before_backup = lib.mkOption {
beforeBackup = lib.mkOption {
description = "Hooks to run before backup";
type = lib.types.listOf lib.types.str;
default = [];
};

after_backup = lib.mkOption {
afterBackup = lib.mkOption {
description = "Hooks to run after backup";
type = lib.types.listOf lib.types.str;
default = [];
Expand Down Expand Up @@ -279,11 +279,11 @@ in
lib.attrsets.mapAttrsToList mkCheck instance.consistency;

# hooks = lib.mkMerge [
# lib.optionalAttrs (builtins.length instance.hooks.before_backup > 0) {
# inherit (instance.hooks) before_backup;
# lib.optionalAttrs (builtins.length instance.hooks.beforeBackup > 0) {
# inherit (instance.hooks) beforeBackup;
# }
# lib.optionalAttrs (builtins.length instance.hooks.after_backup > 0) {
# inherit (instance.hooks) after_backup;
# lib.optionalAttrs (builtins.length instance.hooks.afterBackup > 0) {
# inherit (instance.hooks) afterBackup;
# }
# ];
};
Expand Down
4 changes: 2 additions & 2 deletions modules/blocks/restic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ in
"--${builtins.replaceStrings ["_"] ["-"] name} ${builtins.toString value}"
) instance.settings.retention;

backupPrepareCommand = concatStringsSep "\n" instance.request.hooks.before_backup;
backupPrepareCommand = concatStringsSep "\n" instance.request.hooks.beforeBackup;

backupCleanupCommand = concatStringsSep "\n" instance.request.hooks.after_backup;
backupCleanupCommand = concatStringsSep "\n" instance.request.hooks.afterBackup;

extraBackupArgs =
(optionals (instance.settings.limitUploadKiBs != null) [
Expand Down
4 changes: 2 additions & 2 deletions modules/contracts/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ in
default = {};
type = submodule {
options = {
before_backup = mkOption {
beforeBackup = mkOption {
description = "Hooks to run before backup.";
type = listOf str;
default = [];
};

after_backup = mkOption {
afterBackup = mkOption {
description = "Hooks to run after backup.";
type = listOf str;
default = [];
Expand Down
2 changes: 1 addition & 1 deletion test/blocks/restic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let
"/opt/files/B"
];

hooks.before_backup = [''
hooks.beforeBackup = [''
echo $RUNTIME_DIRECTORY
if [ "$RUNTIME_DIRECTORY" = /run/restic-backups-testinstance_opt_repos_A ]; then
if ! [ -f /run/secrets_restic/restic-backups-testinstance_opt_repos_A ]; then
Expand Down

0 comments on commit ba1e60a

Please sign in to comment.