Skip to content

Commit

Permalink
Still allow PRUNE_KEEP variable to be a string, instead of an array
Browse files Browse the repository at this point in the history
  • Loading branch information
SisyphusMD committed Jun 1, 2024
1 parent d6738b1 commit b93b179
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
11 changes: 0 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Fixed the Duplicacy Prune function. Backup rotations work now.

### Breaking Changes
- The `PRUNE_KEEP` variable in `config.sh` must now be an array instead of a string. Users must update their `config.sh` file accordingly.
- **Old Format**:
```bash
PRUNE_KEEP="-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1"
```
- **New Format**:
```bash
PRUNE_KEEP=(-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1)
```

## [0.1.0] - 2024-05-31
### Added
- Initial release of the project.
2 changes: 1 addition & 1 deletion examples/config.sh.example
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@

# Backup Rotation
# ROTATE_BACKUPS="" # Default: "true". Set to 'true' to enable rotating out older backups.
# PRUNE_KEEP=() # Default: (-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1). See https://forum.duplicacy.com/t/prune-command-details/1005 for details.
# PRUNE_KEEP="" # Default: "-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1". See https://forum.duplicacy.com/t/prune-command-details/1005 for details.
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ EOL
cat <<EOL >> "${ARCHIVER_DIR}/config.sh"
# Backup Rotation
ROTATE_BACKUPS="${rotate_backups}" # Default: "true". Set to 'true' to enable rotating out older backups.
PRUNE_KEEP=(${prune_keep}) # Default: (-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1). See https://forum.duplicacy.com/t/prune-command-details/1005 for details.
PRUNE_KEEP="${prune_keep}" # Default: "-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1". See https://forum.duplicacy.com/t/prune-command-details/1005 for details.
EOL

chown "${CALLER_UID}:${CALLER_GID}" "${ARCHIVER_DIR}/config.sh"
Expand Down
2 changes: 1 addition & 1 deletion utils/duplicacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ duplicacy_wrap_up() {
if [[ "$(echo "${ROTATE_BACKUPS}" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then
# Prune the Duplicacy storage
log_message "INFO" "Running Duplicacy storage '${storage_name}' prune for all repositories."
"${DUPLICACY_BIN}" prune -all -storage "${storage_name}" "${PRUNE_KEEP[@]}" 2>&1 | log_output "duplicacy"
"${DUPLICACY_BIN}" prune -all -storage "${storage_name}" "${PRUNE_KEEP_ARRAY[@]}" 2>&1 | log_output "duplicacy"
exit_status="${PIPESTATUS[0]}"
if [[ "${exit_status}" -ne 0 ]]; then
handle_error "Running Duplicacy storage '${storage_name}' prune failed. Review the Duplicacy logs for details."
Expand Down
10 changes: 7 additions & 3 deletions utils/set-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,20 @@ check_backup_rotation_settings() {
fi

# Check if PRUNE_KEEP is set, if not, assign the default value
if [ "${#PRUNE_KEEP[@]}" -eq 0 ]; then
PRUNE_KEEP=(-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1)
if [ -z "${PRUNE_KEEP}" ]; then
PRUNE_KEEP="-keep 0:180 -keep 30:30 -keep 7:7 -keep 1:1"
fi

declare -a PRUNE_KEEP_ARRAY
read -r -a PRUNE_KEEP_ARRAY <<< "${PRUNE_KEEP}"

# Export the variables if they need to be used outside the function
export ROTATE_BACKUPS
export PRUNE_KEEP
export PRUNE_KEEP_ARRAY

# Log the values being used for backup rotation
log_message "INFO" "Backup rotation settings: ROTATE_BACKUPS=${ROTATE_BACKUPS}, PRUNE_KEEP=${PRUNE_KEEP}"
log_message "INFO" "Backup rotation settings: ROTATE_BACKUPS=${ROTATE_BACKUPS}, PRUNE_KEEP=${PRUNE_KEEP}, PRUNE_KEEP_ARRAY=${PRUNE_KEEP_ARRAY[@]}"
}

# Function to verify the entire configuration
Expand Down

0 comments on commit b93b179

Please sign in to comment.