diff options
Diffstat (limited to 'lib/subcommands/backup.bash')
-rw-r--r-- | lib/subcommands/backup.bash | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/subcommands/backup.bash b/lib/subcommands/backup.bash index 9a23ede..3d56539 100644 --- a/lib/subcommands/backup.bash +++ b/lib/subcommands/backup.bash @@ -22,9 +22,9 @@ subcommand() { then debug "$BASHTARD_NAME/backup" "Retrieving elements from config" - while read -r element + while read -r key do - set -- "$@" "$(config "$element")" + set -- "$@" "$(config "bashtard.backup.elements.$key")" done < <(config_subkeys "bashtard.backup.elements") fi @@ -39,14 +39,12 @@ subcommand() { # Loop over all repositories, and run backup functions for each of them while read -r key do - index="$(awk -F. '{ print $NF }' <<< "$key")" - for element in "$@" do - "backup_$element" "$index" + "backup_$element" "$key" done - info "$BASHTARD_NAME/backup/$index" "Backups completed" + info "$BASHTARD_NAME/backup/$key" "Backups completed" done < <(config_subkeys "bashtard.backup.repositories") } @@ -55,7 +53,6 @@ backup_filesystem() { local borg local cmd_create local cmd_prune - local indexes borg="$(config "bashtard.backup.borg.command" "borg")" remote="$(config "bashtard.backup.borg.remote_paths.$index" "borg")" @@ -75,12 +72,13 @@ backup_filesystem() { "--keep-weekly" "$(config "bashtard.backup.keep.weekly")" "--keep-monthly" "$(config "bashtard.backup.keep.monthly")" "--keep-yearly" "$(config "bashtard.backup.keep.yearly")" - "--prefix" "{fqdn}-" + "--glob-archives" "${BASHTARD_PLATFORM[fqdn]}-" "--remote-path" "$remote" "$repo/hostfs" ) notice "$BASHTARD_NAME/backup/$index" "> ${cmd_prune[*]}" + # shellcheck disable=SC2068 ${cmd_prune[@]} # Create new backups @@ -93,12 +91,13 @@ backup_filesystem() { ) # Add all paths to the command - while read -r path + while read -r key do - cmd_create+=("$(config "$path")") + cmd_create+=("$(config "bashtard.backup.fs.paths.$key")") done < <(config_subkeys "bashtard.backup.fs.paths") notice "$BASHTARD_NAME/backup/$index" "> ${cmd_create[*]}" + # shellcheck disable=SC2068 ${cmd_create[@]} } @@ -145,12 +144,13 @@ backup_database_postgresql() { "--keep-weekly" "$(config "bashtard.backup.keep.weekly")" "--keep-monthly" "$(config "bashtard.backup.keep.monthly")" "--keep-yearly" "$(config "bashtard.backup.keep.yearly")" - "--prefix" "$database-" + "--glob-archives" "$database-" "--remote-path" "$remote" "$repo/postgresql-$database" ) notice "$BASHTARD_NAME/backup/$index" "> ${cmd_prune[*]}" + # shellcheck disable=SC2068 ${cmd_prune[@]} # Create new backups @@ -162,7 +162,8 @@ backup_database_postgresql() { "-" ) - notice "$BASHTARD_NAME/backup/$index" "> pg_dump "$database" | ${cmd_create[*]}" + notice "$BASHTARD_NAME/backup/$index" "> pg_dump $database | ${cmd_create[*]}" + # shellcheck disable=SC2068 pg_dump "$database" | ${cmd_create[@]} done < <(psql -AXt -d template1 -c "SELECT datname FROM pg_database") } |